more refactoring and added test to cover orphan user completing registration with email