Bug 814647 - Fixed small issues with automatic emails, added an important unit test.