refactor tests to remove duplication