Tests, refactoring