minor refactoring for tests.