Fixed email duplication issue, added test classes and cases.