Finally getting around to implementing some unit tests. Some refactoring
involved to enable easier testing.
Merge pull request #60 from Gonthim/master

Finally getting around to implementing some unit tests.