Refactoring tests and test helpers