Added a test class for mail, fixed a few things