adding small refactor + tests