small refactoring + added unit test