Fixed tests
simplified the mail code further