diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc
index e552b04f8c8f99e8c3ed97b77718c65f4d71ec2d..83ca1c0afd66baba4c84869825ce8af67b51b475 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc
@@ -222,7 +222,8 @@ test03()
   std::vector<std::pair<std::string, int>> v;
   v.insert(v.end(), lst.begin(), lst.end());
 
-  auto __offset = __gnu_test::counter::count();
+  const auto origin = __gnu_test::counter::count();
+
   {
     __gnu_test::counter::reset();
     std::unordered_map<std::string, int,
@@ -231,15 +232,19 @@ test03()
     um.insert(v.begin(), v.end());
     VERIFY( um.size() == 1 );
 
-    VERIFY( __gnu_test::counter::count() - __offset == 3 );
-    VERIFY( __gnu_test::counter::get()._M_increments == 3 );
+    // Allocate array of buckets, a node, and the std::string (unless COW).
+    constexpr std::size_t increments = _GLIBCXX_USE_CXX11_ABI ? 3 : 2;
+
+    VERIFY( __gnu_test::counter::count() == origin + increments );
+    VERIFY( __gnu_test::counter::get()._M_increments == increments );
 
     um.insert(v.begin(), v.end());
     VERIFY( um.size() == 1 );
 
-    VERIFY( __gnu_test::counter::count() - __offset == 3 );
-    VERIFY( __gnu_test::counter::get()._M_increments == 3 );
+    VERIFY( __gnu_test::counter::count() == origin + increments );
+    VERIFY( __gnu_test::counter::get()._M_increments == increments );
   }
+  VERIFY( __gnu_test::counter::count() == origin );
 
   {
     __gnu_test::counter::reset();
@@ -250,8 +255,11 @@ test03()
 	      std::make_move_iterator(v.end()));
     VERIFY( um.size() == 1 );
 
-    VERIFY( __gnu_test::counter::count() - __offset == 2 );
-    VERIFY( __gnu_test::counter::get()._M_increments == 2 );
+    // Allocate array of buckets and a node. String is moved.
+    constexpr std::size_t increments = 2;
+
+    VERIFY( __gnu_test::counter::count() == origin + increments );
+    VERIFY( __gnu_test::counter::get()._M_increments == increments );
   }
 }
 
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc
index efb2f9eb6b124ff705636ee86523d67f2dd46ab5..83d5475c6779fe542c98ceda78d246f9589cad2a 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc
@@ -223,7 +223,8 @@ test03()
   std::vector<std::string> v;
   v.insert(v.end(), lst.begin(), lst.end());
 
-  auto __offset = __gnu_test::counter::count();
+  const auto origin = __gnu_test::counter::count();
+
   {
     __gnu_test::counter::reset();
     std::unordered_set<std::string,
@@ -232,15 +233,19 @@ test03()
     us.insert(v.begin(), v.end());
     VERIFY( us.size() == 1 );
 
-    VERIFY( __gnu_test::counter::count() - __offset == 3 );
-    VERIFY( __gnu_test::counter::get()._M_increments == 3 );
+    // Allocate array of buckets, a node, and the std::string (unless COW).
+    constexpr std::size_t increments = _GLIBCXX_USE_CXX11_ABI ? 3 : 2;
+
+    VERIFY( __gnu_test::counter::count() == origin + increments );
+    VERIFY( __gnu_test::counter::get()._M_increments == increments );
 
     us.insert(v.begin(), v.end());
     VERIFY( us.size() == 1 );
 
-    VERIFY( __gnu_test::counter::count() - __offset == 3 );
-    VERIFY( __gnu_test::counter::get()._M_increments == 3 );
+    VERIFY( __gnu_test::counter::count() == origin + increments );
+    VERIFY( __gnu_test::counter::get()._M_increments == increments );
   }
+  VERIFY( __gnu_test::counter::count() == origin );
 
   {
     __gnu_test::counter::reset();
@@ -251,8 +256,11 @@ test03()
 	      std::make_move_iterator(v.end()));
     VERIFY( us.size() == 1 );
 
-    VERIFY( __gnu_test::counter::count() - __offset == 2 );
-    VERIFY( __gnu_test::counter::get()._M_increments == 2 );
+    // Allocate array of buckets and a node. String is moved.
+    constexpr std::size_t increments = 2;
+
+    VERIFY( __gnu_test::counter::count() == origin + increments );
+    VERIFY( __gnu_test::counter::get()._M_increments == increments );
   }
 }