refactor user signup and add some tests