Fixed some errors

- Decorator errors generate the correct status code
- Added utility function for generating the error header
- Added REALM option to settings for specifying the realm
- Fixed the tests to reflect these changes