Refactor code duplication in Handler
Refactor tests
Merge pull request #1 from duckmole/master

Code quality improved by removing code duplication. Thanks @duckmole