some more refactoring for testing