Add UNAUTHORIZED error code constant and use in code and tests
Code review changes