refactor test to remove some duplication