Refactors tests with some helper methods