Refactored code within user registration tests into helper function.