Implemented proper handling of leading variable in the ToolsHome

More info: https://issues.jenkins-ci.org/browse/JENKINS-18815