Refactored the imap transport based on the tests
Testing the switch to uid-based IMAP calls required better testing
The better testing revealed some code that wasn't so pretty

I fixed the tests and the code