Fix wrong parsing of commands.
Externalize the call of imap in order to prepare its inclusion in a backround thread.