Small refactor, add test