refactoring
added tests