Refactoring and added testing.
Merge pull request #1 from zizkovrb/master

Refactoring and added testing.