Fixed config serialisation logic, and added to CLI version to ensure tests check it.