diff --git a/tests/mpi_test_main.cpp b/tests/mpi_test_main.cpp
index ecf49bbe4662ae30ac4b99af694aad4ecfe6a1de..b370c1f8213c2f7bc8b614ddc2684abb5336fe27 100644
--- a/tests/mpi_test_main.cpp
+++ b/tests/mpi_test_main.cpp
@@ -8,13 +8,11 @@
 
 int main( int argc, char* argv[] )
 {
-  setenv("GCOV_PREFIX", "/dev/null", 1);
-
   Messenger::create(argc,  argv);
   Kokkos::initialize({4,-1,-1,true});
 
-  if (commRank() == 0) {
-    unsetenv("GCOV_PREFIX");
+  if (commRank() != 0) {
+    setenv("GCOV_PREFIX", "/dev/null", 1);
   }
 
   int result = Catch::Session().run( argc, argv );