Refactor test helper methods