If an order is illegal an officer is required to disobey it. The court doesn't want to get into that, and I don't blame the judge. However, if they don't want the defense getting into it, they will have to come to a compromise.
Oh, but they can nail him on the two charges of conduct unbecoming an officer.