Smarter array handling in config writer (with tests).