Merge pull request #5 from ianjosephwilson/master

Refactoring and testing.