diff --git a/internal/cmd/match_criteria_test.go b/internal/cmd/match_criteria_test.go
index 0fa44ef..432f977 100644
--- a/internal/cmd/match_criteria_test.go
+++ b/internal/cmd/match_criteria_test.go
@@ -166,7 +166,7 @@ func TestLabelsMatch(t *testing.T) {
 	}
 }
 func TestBranchMatchesCriteria(t *testing.T) {
-	t.Parallel()
+	// Remove t.Parallel() at the function level to avoid races on global variables
 
 	// Define test cases
 	tests := []struct {
@@ -263,10 +263,25 @@ func TestBranchMatchesCriteria(t *testing.T) {
 	}
 
 	for _, test := range tests {
+		test := test // Create a local copy of the test variable to use in the closure
 		t.Run(test.name, func(t *testing.T) {
-			t.Parallel()
+			t.Parallel() // Parallelize at the subtest level, each with their own local variables
+
+			// Save original values of global variables
+			origCombineBranchName := combineBranchName
+			origBranchPrefix := branchPrefix
+			origBranchSuffix := branchSuffix
+			origBranchRegex := branchRegex
+
+			// Restore original values after test
+			defer func() {
+				combineBranchName = origCombineBranchName
+				branchPrefix = origBranchPrefix
+				branchSuffix = origBranchSuffix
+				branchRegex = origBranchRegex
+			}()
 
-			// Set global variables for the test
+			// Set global variables for this specific test
 			combineBranchName = test.combineBranch
 			branchPrefix = test.prefix
 			branchSuffix = test.suffix