First effort to fix JENKINS-23206
introducing unit tests !
simplify detection
refactor
Merge branch 'mathieu-pousse-master'

* mathieu-pousse-master:
  refactor
  simplify detection
  introducing unit tests !
  First effort to fix JENKINS-23206