text: Title: Put user creation logic in a importable function
  Body: Following discussion in #375, I think it would be nice to have a user creation function with all the related logic instead of having it nested in register route.