make methods consistent between IMAP & SFTP
factor out _add_keys_to_upload_queue
code refactorings.