add break loop when job is invalid; fix tests