Fixing rspec syntax warnings and fixing #103 with tests

I've changed the code with the #103 example, and added some tests and the same behaviour to IMAP connection to keep it consistent.

I'm going to work merging some pull-request in few days.