Adding some logic to avoid duplicated email address and user names.
Adding more unit test and some small re-factoring.
Merge pull request #125 from michaelhidalgo/Issue_739

Fixing Issue 739