Added tests. Fixed few minor issues found while writing tests.

Added tests. Fixed few minor issues found while writing tests.
Fixes #5 
Oops, I somehow missed that this pull *does* bump the version. I'm guessing it's because of the "issues found while writing tests". Those issues should be listed here as fixed bugs in the CHANGELOG.