some refactoring
added test