I see that you've got some code that's working, but if you want to extend it more, I'll recommend a unit test library I wrote. You might find some unit tests helpful to know when your code is working. The library is https://bitbucket.org/zck/unit-test.arc/ .
You'll make unit tests inside a test suite, like so: