Additional tests
Refactoring and comments