De-duplicate code in unit tests