Fix unit tests

Some small ugly refactor to recover some tests from the modules mail and mailfilter.