refactors, added some unit tests
Merge branch 'master' of github.com:simplydragons/mercury