Clean up the Settings codebase.

* add more tests
* add documentation
* raise helpful error messages
Merge pull request #15 from nature/settings-fix

Clean up the Settings codebase.