Add unit test for gate resolution

Work in progress.

Fixed error in globalphase