imap: Reworked the logic of untagged command responses