Refactor out some test duplication