A bit of refactoring for unit tests