Fix return code handling of config_testcd() + slightly refactor code