fixed variable-scope bug in gate tests