Ensure conflicting pending flags are handled in order

If there are pending flag changes both setting and clearing a certain
flag for a certain message, ensure that the latest action wins.

We no longer batch combinations of several flags into a single UID STORE
command, but the loss of that optimisation should be negligible.