Added test for pre-save email downcasing, and refactored relevant code