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

Finally getting around to implementing some unit tests.