diff --git a/test-salt-formulas-env.groovy b/test-salt-formulas-env.groovy
index 486bd3a..257c0ab 100644
--- a/test-salt-formulas-env.groovy
+++ b/test-salt-formulas-env.groovy
@@ -24,7 +24,9 @@
 
 def checkouted = false
 def openstackTest = false
-def cleanEnv = ''
+def travisLess = false      /** TODO: Remove once formulas are witched to new config */
+def cleanEnv = ''           /** TODO: Remove once formulas are witched to new config */
+def testSuite = ''
 
 throttle(['test-formula']) {
   timeout(time: 1, unit: 'HOURS') {
@@ -43,69 +45,116 @@
           }
         }
         stage("kitchen") {
-          if (checkouted) {
-            if (fileExists(".kitchen.yml") || fileExists(".kitchen.openstack.yml")) {
-              if (fileExists(".kitchen.openstack.yml")) {
-                common.infoMsg("Openstack Kitchen test configuration found, running Openstack kitchen tests.")
-                if (fileExists(".kitchen.yml")) {
-                  common.infoMsg("Ignoring the docker Kitchen test configuration file.")
+          if (fileExists(".travis.yml")) {/** TODO: Remove this legacy block once formulas are witched to new config */
+            if (checkouted) {
+              if (fileExists(".kitchen.yml") || fileExists(".kitchen.openstack.yml")) {
+                if (fileExists(".kitchen.openstack.yml")) {
+                  common.infoMsg("Openstack Kitchen test configuration found, running Openstack kitchen tests.")
+                  if (fileExists(".kitchen.yml")) {
+                    common.infoMsg("Ignoring the docker Kitchen test configuration file.")
+                  }
+                  openstackTest = true
+                } else {
+                  common.infoMsg("Docker Kitchen test configuration found, running Docker kitchen tests.")
                 }
-                openstackTest = true
-              } else {
-                common.infoMsg("Docker Kitchen test configuration found, running Docker kitchen tests.")
-              }
-              ruby.ensureRubyEnv()
-              if (fileExists(".travis.yml")) {
-                common.infoMsg(".travis.yml found, running custom kitchen init")
-                def kitchenConfigYML = readYaml(file: ".travis.yml")
-                def kitchenInit = kitchenConfigYML["install"]
-                def kitchenInstalled = false
-                if (kitchenInit && !kitchenInit.isEmpty()) {
-                  for (int i = 0; i < kitchenInit.size(); i++) {
-                    if (kitchenInit[i].trim().startsWith("if [ ! -e Gemfile ]")) { //found Gemfile config
-                      common.infoMsg("Custom Gemfile configuration found, using them")
-                      if (openstackTest) {
-                        withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: openstack_credentials_id,
-                        usernameVariable: 'OS_USERNAME', passwordVariable: 'OS_PASSWORD'], ]) {
-                          env.OS_USERNAME = OS_USERNAME
-                          env.OS_PASSWORD = OS_PASSWORD
-                          env.OS_AUTH_URL = OS_AUTH_URL
-                          env.OS_PROJECT_NAME = OS_PROJECT_NAME
-                          env.OS_DOMAIN_NAME = OS_DOMAIN_NAME
-                          env.OS_AZ = OS_AZ
+                ruby.ensureRubyEnv()
+                if (fileExists(".travis.yml")) {
+                  common.infoMsg(".travis.yml found, running custom kitchen init")
+                  def kitchenConfigYML = readYaml(file: ".travis.yml")
+                  def kitchenInit = kitchenConfigYML["install"]
+                  def kitchenInstalled = false
+                  if (kitchenInit && !kitchenInit.isEmpty()) {
+                    for (int i = 0; i < kitchenInit.size(); i++) {
+                      if (kitchenInit[i].trim().startsWith("if [ ! -e Gemfile ]")) { //found Gemfile config
+                        common.infoMsg("Custom Gemfile configuration found, using them")
+                        if (openstackTest) {
+                          withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: openstack_credentials_id,
+                          usernameVariable: 'OS_USERNAME', passwordVariable: 'OS_PASSWORD'], ]) {
+                            env.OS_USERNAME = OS_USERNAME
+                            env.OS_PASSWORD = OS_PASSWORD
+                            env.OS_AUTH_URL = OS_AUTH_URL
+                            env.OS_PROJECT_NAME = OS_PROJECT_NAME
+                            env.OS_DOMAIN_NAME = OS_DOMAIN_NAME
+                            env.OS_AZ = OS_AZ
+                          }
                         }
+                        ruby.installKitchen(kitchenInit[i].trim())
+                        kitchenInstalled = true
                       }
-                      ruby.installKitchen(kitchenInit[i].trim())
-                      kitchenInstalled = true
                     }
                   }
-                }
-                if (!kitchenInstalled) {
+                  if (!kitchenInstalled) {
+                    ruby.installKitchen()
+                  }
+                } else {
+                  common.infoMsg(".travis.yml not found, running default kitchen init")
                   ruby.installKitchen()
                 }
-              } else {
-                common.infoMsg(".travis.yml not found, running default kitchen init")
-                ruby.installKitchen()
-              }
-              common.infoMsg("Running part of kitchen test")
-              if (KITCHEN_ENV != null && !KITCHEN_ENV.isEmpty() && KITCHEN_ENV != "") {
-                cleanEnv = KITCHEN_ENV.replaceAll("\\s?SUITE=[^\\s]*", "")
-                if (openstackTest) { cleanEnv = "KITCHEN_YAML=.kitchen.openstack.yml " + cleanEnv }
-                sh("grep apt.mirantis.com -Ril | xargs -I{} bash -c \"echo {}; sed -i 's/apt.mirantis.com/apt.mcp.mirantis.net/g' {}\"")
-                sh("grep apt-mk.mirantis.com -Ril | xargs -I{} bash -c \"echo {}; sed -i 's/apt-mk.mirantis.com/apt.mcp.mirantis.net/g' {}\"")
-                def suite = ruby.getSuiteName(KITCHEN_ENV)
-                if (suite && suite != "") {
-                  common.infoMsg("Running kitchen test with environment:" + KITCHEN_ENV.trim())
-                  ruby.runKitchenTests(cleanEnv, suite)
+                common.infoMsg("Running part of kitchen test")
+                if (KITCHEN_ENV != null && !KITCHEN_ENV.isEmpty() && KITCHEN_ENV != "") {
+                  cleanEnv = KITCHEN_ENV.replaceAll("\\s?SUITE=[^\\s]*", "")
+                  if (openstackTest) { cleanEnv = "KITCHEN_YAML=.kitchen.openstack.yml " + cleanEnv }
+                  sh("grep apt.mirantis.com -Ril | xargs -I{} bash -c \"echo {}; sed -i 's/apt.mirantis.com/apt.mcp.mirantis.net/g' {}\"")
+                  sh("grep apt-mk.mirantis.com -Ril | xargs -I{} bash -c \"echo {}; sed -i 's/apt-mk.mirantis.com/apt.mcp.mirantis.net/g' {}\"")
+                  def suite = ruby.getSuiteName(KITCHEN_ENV)
+                  if (suite && suite != "") {
+                    common.infoMsg("Running kitchen test with environment:" + KITCHEN_ENV.trim())
+                    ruby.runKitchenTests(cleanEnv, suite)
+                  } else {
+                    common.warningMsg("No SUITE was found. Running with all suites.")
+                    ruby.runKitchenTests(cleanEnv, "")
+                  }
                 } else {
-                  common.warningMsg("No SUITE was found. Running with all suites.")
-                  ruby.runKitchenTests(cleanEnv, "")
+                  throw new Exception("KITCHEN_ENV parameter is empty or invalid. This may indicate wrong env settings of initial test job or .travis.yml file.")
                 }
               } else {
-                throw new Exception("KITCHEN_ENV parameter is empty or invalid. This may indicate wrong env settings of initial test job or .travis.yml file.")
+                throw new Exception(".kitchen.yml file not found, no kitchen tests triggered.")
               }
-            } else {
-              throw new Exception(".kitchen.yml file not found, no kitchen tests triggered.")
+            }/** TODO: End of block for removal */
+          } else {
+            if (checkouted) {
+              travisLess = true
+              if (fileExists(".kitchen.yml") || fileExists(".kitchen.openstack.yml")) {
+                if (fileExists(".kitchen.openstack.yml")) {
+                  common.infoMsg("Openstack Kitchen test configuration found, running Openstack kitchen tests.")
+                  if (fileExists(".kitchen.yml")) {
+                    common.infoMsg("Ignoring the docker Kitchen test configuration file.")
+                  }
+                  openstackTest = true
+                  withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: openstack_credentials_id,
+                  usernameVariable: 'OS_USERNAME', passwordVariable: 'OS_PASSWORD'], ]) {
+                    env.OS_USERNAME = OS_USERNAME
+                    env.OS_PASSWORD = OS_PASSWORD
+                    env.OS_AUTH_URL = OS_AUTH_URL
+                    env.OS_PROJECT_NAME = OS_PROJECT_NAME
+                    env.OS_DOMAIN_NAME = OS_DOMAIN_NAME
+                    env.OS_AZ = OS_AZ
+                  }
+                } else {
+                  common.infoMsg("Docker Kitchen test configuration found, running Docker kitchen tests.")
+                }
+                ruby.ensureRubyEnv()
+                if (!fileExists("Gemfile")) {
+                  sh("curl -s -o ./Gemfile 'https://gerrit.mcp.mirantis.com/gitweb?p=salt-formulas/salt-formulas-scripts.git;a=blob_plain;f=Gemfile;hb=refs/heads/master'")
+                  ruby.installKitchen()
+                } else {
+                  common.infoMsg("Override Gemfile found in the kitchen directory, using it.")
+                  ruby.installKitchen()
+                }
+                common.infoMsg("Running part of kitchen test")
+                if (KITCHEN_ENV != null && !KITCHEN_ENV.isEmpty() && KITCHEN_ENV != "") {
+                  testSuite = KITCHEN_ENV.replaceAll("_", "-").trim()
+                  if (openstackTest) { testSuite = "KITCHEN_YAML=.kitchen.openstack.yml " + testSuite }
+                  sh("grep apt.mirantis.com -Ril | xargs -I{} bash -c \"echo {}; sed -i 's/apt.mirantis.com/apt.mcp.mirantis.net/g' {}\"")
+                  sh("grep apt-mk.mirantis.com -Ril | xargs -I{} bash -c \"echo {}; sed -i 's/apt-mk.mirantis.com/apt.mcp.mirantis.net/g' {}\"")
+                  common.infoMsg("Running kitchen test with environment:" + testSuite)
+                  ruby.runKitchenTests("", testSuite)
+                } else {
+                  throw new Exception("KITCHEN_ENV parameter is empty or invalid. This may indicate wrong env settings of initial test job or .travis.yml file.")
+                }
+              } else {
+                throw new Exception(".kitchen.yml file not found, no kitchen tests triggered.")
+              }
             }
           }
         }
@@ -113,7 +162,11 @@
         // If there was an error or exception thrown, the build failed
         currentBuild.result = "FAILURE"
         sh(script: 'find .kitchen/logs/ -type f -iname "*.log" | xargs -I{} bash -c "echo {}; cat {}"')
-        ruby.runKitchenCommand("destroy", cleanEnv)
+        if (travisLess) {
+          ruby.runKitchenCommand("destroy", testSuite)
+        } else {
+          ruby.runKitchenCommand("destroy", cleanEnv)  /** TODO: Remove once formulas are witched to new config */
+        }
         throw e
       } finally {
         if (currentBuild.result == "FAILURE" && fileExists(".kitchen/logs/kitchen.log")) {
