Add MailerTest file and refactoring