Some refactoring in tests