diff --git a/integration-tests/code/getKSAKeyTest/getKSA_key_test.go b/integration-tests/code/getKSAKeyTest/getKSA_key_test.go
index a1b9c137ae15a22d7216983f6cc6135d40f2bcc7..d58caae8ed722717443bf8d3b95897f88412ccda 100644
--- a/integration-tests/code/getKSAKeyTest/getKSA_key_test.go
+++ b/integration-tests/code/getKSAKeyTest/getKSA_key_test.go
@@ -79,15 +79,24 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo
 		logFileURL2 = logFileURL_ENV2
 	}
 
+	// TLS stuff
 	tlsConfig := config.TLSConfig{
 		Active:   true,
 		CAFile:   "../../../artifacts/integration-tests/ssl/ca.crt",
 		CertFile: "../../../artifacts/integration-tests/ssl/integration_test.crt",
 		KeyFile:  "../../../artifacts/integration-tests/ssl/integration_test.key",
 	}
+	tlsConf, err := kmstls.GenerateTLSLibraryConfig(tlsConfig)
+	if err != nil {
+		t.Errorf("Error generating TLS config: %s", err)
+	}
+	transport := &http.Transport{
+		TLSClientConfig: tlsConf,
+	}
+	client := &http.Client{Transport: transport}
 
 	// Tell the qkdn-controller what devices to use.
-	_, err := utils.RunGosdncScript(gosdncScript, controllerURL)
+	_, err = utils.RunGosdncScript(gosdncScript, controllerURL)
 	if err != nil {
 		currentFolderPath := os.Getenv("PWD")
 		t.Errorf("Error running gosdnc script. Current folder path: %s, Error: %s", currentFolderPath, err)
@@ -108,15 +117,6 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo
 		},
 	}
 
-	tlsConf, err := kmstls.GenerateTLSLibraryConfig(tlsConfig)
-	if err != nil {
-		t.Errorf("Error generating TLS config: %s", err)
-	}
-	transport := &http.Transport{
-		TLSClientConfig: tlsConf,
-	}
-	client := &http.Client{Transport: transport}
-
 	jsonData, err := json.Marshal(data)
 	if err != nil {
 		fmt.Println(err)