Correct various bugs in the recovery mechanism

The namespace of the selected mailbox was not properly applied after
recovery, CRAM-MD5 authentication during the recovery would fail, and
searching after recovery could fail in some cases.