Further test refactoring to remove duplication.