Fixed config validation bug; simplified code.
- Includes tests.