fix missing ) and refactor the test phase state out