Refactor setting up the tests for gates.