Add tests for server-side resource server. Fix bugs. Refactor.
Refactor 401 error handling in resource server.
Add tests for ResourceServer in browser.