diff --git a/CRM/Utils/System/UnitTests.php b/CRM/Utils/System/UnitTests.php
index 14762fff7f1f3e9f360bf051aa471f66ca48b578..ee53a4a2c4c45d3f93926f0506253d72bccbffbb 100644
--- a/CRM/Utils/System/UnitTests.php
+++ b/CRM/Utils/System/UnitTests.php
@@ -92,7 +92,7 @@ class CRM_Utils_System_UnitTests extends CRM_Utils_System_Base {
     }
     $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase;
 
-    $separator = $htmlize ? '&' : '&';
+    $separator = ($htmlize && $frontend) ? '&' : '&';
 
     if (!$config->cleanURL) {
       if (isset($path)) {