Configuration refinements

Improve the code quality of the configuration sub-system:
remove some duplications, reduce method complexity, remove some unused code,
add some new test cases, improve code coverage.