refactoring
implemented more tests, refactoring