Some refactoring for tests.