Fix bugs.
Merge pull request #26 from emtwo/unit-tests

Fix bugs.