Refactor, tests