Refactored code for better testability
Merge pull request #1 from iljabauer/master

Refactored code for better testability