Add folder select to connection setup

To avoid rampant 'Can't XXX in state AUTH, must be in SELECTED'
type errors from the IMAP server, add a default SELECT command
to the current folder to the connection setup code.
Fix off-by-one error in consolidation code