small refactoring +tests