Refactor test_helper