Fix broken Python3 tests

Needed imap substitution for Py3.