Govt does flip-flop in court on gay sex