[ktest] improve error reporting when config file has invalid format (also fixes a bug)

See commit logs.
@dwightguth where to add unit tests for this function?