Some refactorings for tests