Refactor users resource and add more tests