Support returning one item when using UIDs.
Fix UID-based logic since the former didn't work on all IMAP servers.