Minor refactoring for unit tests