Fixing JENKINS-22750, regression introduced in JENKINS-21394
Fixed test and refined behaviour
Merge pull request #1215 from MadsNielsen/JENKINS-21394-Regression

Fixing JENKINS-22750, regression introduced in JENKINS-21394
Noting #1215