Bug 814647 - Fixed small issues with automatic emails, added an importan...

...t unit test.