some refactoring for unit tests