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, fix some code standard mistakes.
`getDirs` can return `null`. it seems their is a path missing handling that?