small refactor and test