small refactor changes and tests