Further consolidate duplicated code in a unit test