Added some tests + fixed some bugs.
Merge pull request #26 from chrispitt/add-some-tests

Added some tests + fixed some bugs.