added changeGate function and tests