add tests, refactoring application