added tests
refactoring