Added fixes as Christoph Torens says in JENKINS-15438

See https://issues.jenkins-ci.org/browse/JENKINS-15438