small refactoring + added some extra tests