Fix parsing when CNAME is provided for MX query

The code was assuming that the record type was
MX even though this could be false. Also adjusted
some code to also make it easier to test.

Note: the behavior when MX records are missing
is probably still not right.

Closes PR 13654
Fix `imap-list-child-mailboxes` to match contract

Closes PR 13658
Fix old style contracts