some refactoring, add first unit test