Tests, refactorings