fixes #64, added tests for that, minor refactoring
Merge pull request #65 from zelgerj/master

fixes #64, added tests for that, minor refactoring