Add test cases for user.js and move the validation from front to back end.