Test refactorings and more tests