Added more tests for mailbuild

Some new tests and some refactoring for existing ones