diff --git a/src/UnitTests/AssertCudaTest.cu b/src/UnitTests/AssertCudaTest.cu
index cfd4e846b718edf2481e49cec45023a7ef757a81..9d4865eb9c8ba3b7aaa6f8bf5506fabe17be4483 100644
--- a/src/UnitTests/AssertCudaTest.cu
+++ b/src/UnitTests/AssertCudaTest.cu
@@ -108,13 +108,4 @@ WRAP_ASSERT( test28, TNL_ASSERT_FALSE( data_full, "non-nullptr is false" );, fal
 #endif
 #endif
 
-#include "GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "main.h"
diff --git a/src/UnitTests/AssertTest.cpp b/src/UnitTests/AssertTest.cpp
index ea20f7957a3fb4103b482d6a7650f4d3902de191..88bbcf4bee40cc82099281f4026285bc0d3fb238 100644
--- a/src/UnitTests/AssertTest.cpp
+++ b/src/UnitTests/AssertTest.cpp
@@ -68,13 +68,4 @@ TEST( AssertTest, basicTest )
 }
 #endif
 
-#include "GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "main.h"
diff --git a/src/UnitTests/Containers/ArrayOperationsTest.h b/src/UnitTests/Containers/ArrayOperationsTest.h
index 23b8fcd4ebfef2dfd36b75582cd2b14652988abd..4c1b6b9c2ced4d380e93f1056cafab50b0335b64 100644
--- a/src/UnitTests/Containers/ArrayOperationsTest.h
+++ b/src/UnitTests/Containers/ArrayOperationsTest.h
@@ -442,13 +442,4 @@ TYPED_TEST( ArrayOperationsTest, containsOnlyValue_cuda )
 #endif // HAVE_GTEST
 
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Containers/ArrayTest.h b/src/UnitTests/Containers/ArrayTest.h
index 62bf493cbc1d10ec4fcd8f5bb67c7ca0d7a58a8a..dc054e1a8625ec9b0b814b7ce5d6e27c4419fa14 100644
--- a/src/UnitTests/Containers/ArrayTest.h
+++ b/src/UnitTests/Containers/ArrayTest.h
@@ -525,13 +525,4 @@ TYPED_TEST( ArrayTest, boundLoad )
 #endif // HAVE_GTEST
 
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Containers/ArrayViewTest.h b/src/UnitTests/Containers/ArrayViewTest.h
index 28d8b512b1d4ed403b8fd071b13461a163aff2fe..914d5a581251d1d3d1a2c94df35f8c13b052bbc6 100644
--- a/src/UnitTests/Containers/ArrayViewTest.h
+++ b/src/UnitTests/Containers/ArrayViewTest.h
@@ -545,13 +545,4 @@ TYPED_TEST( ArrayViewTest, assignmentOperatorWithDifferentType )
 #endif // HAVE_GTEST
 
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Containers/DistributedArrayTest.h b/src/UnitTests/Containers/DistributedArrayTest.h
index 381539af6b72ec44ce6f62497e2b1530d8edc9f9..03d94ccbe3693d9e1a9c1f0221101de7f1d01698 100644
--- a/src/UnitTests/Containers/DistributedArrayTest.h
+++ b/src/UnitTests/Containers/DistributedArrayTest.h
@@ -11,7 +11,6 @@
 
 #include <TNL/Communicators/MpiCommunicator.h>
 #include <TNL/Communicators/NoDistrCommunicator.h>
-#include <TNL/Communicators/ScopedInitializer.h>
 #include <TNL/Containers/DistributedArray.h>
 #include <TNL/Containers/Partitioner.h>
 
@@ -288,63 +287,4 @@ TYPED_TEST( DistributedArrayTest, boolOperator )
 
 #endif  // HAVE_GTEST
 
-
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-using CommunicatorType = Communicators::MpiCommunicator;
-
-#include <sstream>
-
-class MinimalistBufferedPrinter
-: public ::testing::EmptyTestEventListener
-{
-private:
-   std::stringstream sout;
-
-public:
-   // Called before a test starts.
-   virtual void OnTestStart(const ::testing::TestInfo& test_info)
-   {
-      sout << test_info.test_case_name() << "." << test_info.name() << " Start." << std::endl;
-   }
-
-   // Called after a failed assertion or a SUCCEED() invocation.
-   virtual void OnTestPartResult(const ::testing::TestPartResult& test_part_result)
-   {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ")
-           << test_part_result.file_name() << " "
-           << test_part_result.line_number() <<std::endl
-           << test_part_result.summary() <<std::endl;
-   }
-
-   // Called after a test ends.
-   virtual void OnTestEnd(const ::testing::TestInfo& test_info)
-   {
-      const int rank = CommunicatorType::GetRank(CommunicatorType::AllGroup);
-      sout << test_info.test_case_name() << "." << test_info.name() << " End." <<std::endl;
-      std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-      sout.str( std::string() );
-      sout.clear();
-   }
-};
-#endif
-
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-   #ifdef HAVE_MPI
-      ::testing::TestEventListeners& listeners =
-         ::testing::UnitTest::GetInstance()->listeners();
-
-      delete listeners.Release(listeners.default_result_printer());
-      listeners.Append(new MinimalistBufferedPrinter);
-
-      Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-   #endif
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main_mpi.h"
diff --git a/src/UnitTests/Containers/DistributedVectorTest.h b/src/UnitTests/Containers/DistributedVectorTest.h
index 870446d15a39a0543f4a33f9b05b5f679d15272f..3b52055f44a3519d9ced4bea873f08ced14b5005 100644
--- a/src/UnitTests/Containers/DistributedVectorTest.h
+++ b/src/UnitTests/Containers/DistributedVectorTest.h
@@ -44,7 +44,6 @@ void setNegativeLinearSequence( Vector& deviceVector )
 
 #include <TNL/Communicators/MpiCommunicator.h>
 #include <TNL/Communicators/NoDistrCommunicator.h>
-#include <TNL/Communicators/ScopedInitializer.h>
 #include <TNL/Containers/DistributedVector.h>
 #include <TNL/Containers/DistributedVectorView.h>
 #include <TNL/Containers/Partitioner.h>
@@ -349,63 +348,4 @@ TYPED_TEST( DistributedVectorTest, addVectors )
 
 #endif  // HAVE_GTEST
 
-
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-using CommunicatorType = Communicators::MpiCommunicator;
-
-#include <sstream>
-
-class MinimalistBufferedPrinter
-: public ::testing::EmptyTestEventListener
-{
-private:
-   std::stringstream sout;
-
-public:
-   // Called before a test starts.
-   virtual void OnTestStart(const ::testing::TestInfo& test_info)
-   {
-      sout << test_info.test_case_name() << "." << test_info.name() << " Start." << std::endl;
-   }
-
-   // Called after a failed assertion or a SUCCEED() invocation.
-   virtual void OnTestPartResult(const ::testing::TestPartResult& test_part_result)
-   {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ")
-           << test_part_result.file_name() << " "
-           << test_part_result.line_number() <<std::endl
-           << test_part_result.summary() <<std::endl;
-   }
-
-   // Called after a test ends.
-   virtual void OnTestEnd(const ::testing::TestInfo& test_info)
-   {
-      int rank=CommunicatorType::GetRank(CommunicatorType::AllGroup);
-      sout << test_info.test_case_name() << "." << test_info.name() << " End." <<std::endl;
-      std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-      sout.str( std::string() );
-      sout.clear();
-   }
-};
-#endif
-
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-   #ifdef HAVE_MPI
-      ::testing::TestEventListeners& listeners =
-         ::testing::UnitTest::GetInstance()->listeners();
-
-      delete listeners.Release(listeners.default_result_printer());
-      listeners.Append(new MinimalistBufferedPrinter);
-
-      Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-   #endif
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main_mpi.h"
diff --git a/src/UnitTests/Containers/ListTest.cpp b/src/UnitTests/Containers/ListTest.cpp
index 32e65c22318a4059c981e9fb38bd93de22a2e5da..8330e5268a3ddc6adfa6a20db1137595c542fd83 100644
--- a/src/UnitTests/Containers/ListTest.cpp
+++ b/src/UnitTests/Containers/ListTest.cpp
@@ -143,13 +143,4 @@ TYPED_TEST( ListTest, operations )
 #endif
 
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Containers/Multimaps/MultimapTest.cpp b/src/UnitTests/Containers/Multimaps/MultimapTest.cpp
index 4612c1dd3709efcc470fee9b70e0d3a359b6a693..1ba445e2c62a0c2968a321b16d1b2780cc22f553 100644
--- a/src/UnitTests/Containers/Multimaps/MultimapTest.cpp
+++ b/src/UnitTests/Containers/Multimaps/MultimapTest.cpp
@@ -7,7 +7,7 @@ using IndexType = int;
 using Device = Devices::Host;
 using LocalIndexType = short;
 
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 #include <gtest/gtest.h>
 
 TEST( MultimapTest, TestTypedefs )
@@ -147,12 +147,4 @@ TEST( MultimapTest, TestSaveAndLoad )
 }
 #endif
 
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   return EXIT_FAILURE;
-#endif
-}
+#include "../../main.h"
diff --git a/src/UnitTests/Containers/Multimaps/StaticMultimapTest.cpp b/src/UnitTests/Containers/Multimaps/StaticMultimapTest.cpp
index 3602f53ca83708f874bd5a4492ec751800b4876f..d4ad0bcf732be391633ae78651dfa83707ffd3c0 100644
--- a/src/UnitTests/Containers/Multimaps/StaticMultimapTest.cpp
+++ b/src/UnitTests/Containers/Multimaps/StaticMultimapTest.cpp
@@ -7,7 +7,7 @@ using IndexType = int;
 using Device = Devices::Host;
 using LocalIndexType = short;
 
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 #include <gtest/gtest.h>
 
 TEST( MultimapTest, TestTypedefs )
@@ -95,12 +95,4 @@ TEST( MultimapTest, TestSaveAndLoad )
 }
 #endif
 
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   return EXIT_FAILURE;
-#endif
-}
+#include "../../main.h"
diff --git a/src/UnitTests/Containers/MultireductionTest.h b/src/UnitTests/Containers/MultireductionTest.h
index d0aa7bd84d536480581d2bdc9023b81fe174680d..0487e916b8080bec0ead292ddb95725d8f84533a 100644
--- a/src/UnitTests/Containers/MultireductionTest.h
+++ b/src/UnitTests/Containers/MultireductionTest.h
@@ -120,13 +120,4 @@ TYPED_TEST( MultireductionTest, scalarProduct )
 #endif // HAVE_GTEST
 
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Containers/StaticArrayTest.cpp b/src/UnitTests/Containers/StaticArrayTest.cpp
index 1297933e76d58beb1750e5c85f9b177dc1867644..f1f6b208d2026323ce7d8713c14978ee8ca7ce13 100644
--- a/src/UnitTests/Containers/StaticArrayTest.cpp
+++ b/src/UnitTests/Containers/StaticArrayTest.cpp
@@ -283,13 +283,4 @@ TYPED_TEST( StaticArrayTest, streamOperator )
 #endif // HAVE_GTEST
 
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Containers/StaticVectorTest.cpp b/src/UnitTests/Containers/StaticVectorTest.cpp
index e34db3f33833dc3254e13bc0b2c650a2613abd22..3f39c5045289420671402e27afaf90ac34f64aeb 100644
--- a/src/UnitTests/Containers/StaticVectorTest.cpp
+++ b/src/UnitTests/Containers/StaticVectorTest.cpp
@@ -191,13 +191,4 @@ TYPED_TEST( StaticVectorTest, lpNorm )
 #endif
 
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Containers/VectorTest.h b/src/UnitTests/Containers/VectorTest.h
index 5f84245165145e32a784e6c9792ec2f33361e21d..c223a7afd064264d627ce0d29d9265ef9f054cb0 100644
--- a/src/UnitTests/Containers/VectorTest.h
+++ b/src/UnitTests/Containers/VectorTest.h
@@ -791,13 +791,4 @@ TEST( VectorSpecialCasesTest, defaultConstructors )
 #endif // HAVE_GTEST
 
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/FileNameTest.cpp b/src/UnitTests/FileNameTest.cpp
index 5a69a1f2882d18f7a19928e70bd93c8586ecaefc..b731db6a08e535084483b7bb3a68567bdcbe105f 100644
--- a/src/UnitTests/FileNameTest.cpp
+++ b/src/UnitTests/FileNameTest.cpp
@@ -75,15 +75,4 @@ TEST( FileNameTest, AllTogether )
 }
 #endif
 
-
-#include "GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
-
+#include "main.h"
diff --git a/src/UnitTests/FileTest.h b/src/UnitTests/FileTest.h
index 4a69fcb202b69f36ec06e70feddfabb4831a960c..1e0db34f4a5eaddca481c9c3d78f2dbae5ac6024 100644
--- a/src/UnitTests/FileTest.h
+++ b/src/UnitTests/FileTest.h
@@ -205,13 +205,4 @@ TEST( FileTest, WriteAndReadCUDAWithConversion )
 #endif
 #endif
 
-#include "GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "main.h"
diff --git a/src/UnitTests/Functions/BoundaryMeshFunctionTest.h b/src/UnitTests/Functions/BoundaryMeshFunctionTest.h
index bab8bf5afbac9fa4f4c62d0a42f64facfeb72c12..d3e0a48f5598b5d955297f6af61e65ce8bf34d2a 100644
--- a/src/UnitTests/Functions/BoundaryMeshFunctionTest.h
+++ b/src/UnitTests/Functions/BoundaryMeshFunctionTest.h
@@ -10,9 +10,7 @@
 
 #pragma once
 
-#include "../GtestMissingError.h"
-
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 #include <gtest/gtest.h>
 #include <TNL/Functions/BoundaryMeshFunction.h>
 #include <TNL/Meshes/Grid.h>
@@ -22,16 +20,7 @@ TEST( BoundaryMeshFunctionTest, BasicConstructor )
    using Grid = TNL::Meshes::Grid< 2 >;
    TNL::Functions::BoundaryMeshFunction< Grid > boundaryMesh;
 }
-
 #endif
 
 
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Functions/MeshFunctionTest.h b/src/UnitTests/Functions/MeshFunctionTest.h
index b60daf091a291579f3c4e50318805ed2dc699163..8c8b77c0904690d6b478c1a94c7153de872920a5 100644
--- a/src/UnitTests/Functions/MeshFunctionTest.h
+++ b/src/UnitTests/Functions/MeshFunctionTest.h
@@ -10,9 +10,7 @@
 
 #pragma once
 
-#include "../GtestMissingError.h"
-
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 #include <gtest/gtest.h>
 #include <sstream>
 #include <TNL/Functions/MeshFunction.h>
@@ -35,7 +33,7 @@ TEST( MeshFunctionTest, OstreamOperatorTest )
    grid->setDimensions( CoordinatesType( 3, 3 ) );
    MeshFunctionType meshFunction( grid );
    meshFunction.getData().setValue( 1.0 );
-   
+
    const char* str = "[ 1, 1, 1, 1, 1, 1, 1, 1, 1 ]";
    std::stringstream string_stream1, string_stream2( str );
    string_stream1 << meshFunction;
@@ -46,12 +44,4 @@ TEST( MeshFunctionTest, OstreamOperatorTest )
 #endif
 
 
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Matrices/DenseMatrixTest.h b/src/UnitTests/Matrices/DenseMatrixTest.h
index ea4b6174dce9691c86ac2869362e326996642b9b..f1661c997ec528638a5d586cee530e803dfb499f 100644
--- a/src/UnitTests/Matrices/DenseMatrixTest.h
+++ b/src/UnitTests/Matrices/DenseMatrixTest.h
@@ -1651,14 +1651,4 @@ TEST( DenseMatrixTest, Dense_performSORIterationTest_Cuda )
 
 #endif
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
-
+#include "../main.h"
diff --git a/src/UnitTests/Matrices/DistributedMatrixTest.h b/src/UnitTests/Matrices/DistributedMatrixTest.h
index 2400b7a9ed17bc9758739c5ddd056af770551638..a2170dd1e97751110cdc5c0edab1a91ec01acdae 100644
--- a/src/UnitTests/Matrices/DistributedMatrixTest.h
+++ b/src/UnitTests/Matrices/DistributedMatrixTest.h
@@ -41,7 +41,6 @@ void setMatrix( Matrix& matrix, const RowLengths& rowLengths )
 
 #include <TNL/Communicators/MpiCommunicator.h>
 #include <TNL/Communicators/NoDistrCommunicator.h>
-#include <TNL/Communicators/ScopedInitializer.h>
 #include <TNL/Matrices/DistributedMatrix.h>
 #include <TNL/Containers/Partitioner.h>
 #include <TNL/Matrices/CSR.h>
@@ -237,63 +236,4 @@ TYPED_TEST( DistributedMatrixTest, vectorProduct_distributedInput )
 
 #endif  // HAVE_GTEST
 
-
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-using CommunicatorType = Communicators::MpiCommunicator;
-
-#include <sstream>
-
-class MinimalistBufferedPrinter
-: public ::testing::EmptyTestEventListener
-{
-private:
-   std::stringstream sout;
-
-public:
-   // Called before a test starts.
-   virtual void OnTestStart(const ::testing::TestInfo& test_info)
-   {
-      sout << test_info.test_case_name() << "." << test_info.name() << " Start." << std::endl;
-   }
-
-   // Called after a failed assertion or a SUCCEED() invocation.
-   virtual void OnTestPartResult(const ::testing::TestPartResult& test_part_result)
-   {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ")
-           << test_part_result.file_name() << " "
-           << test_part_result.line_number() <<std::endl
-           << test_part_result.summary() <<std::endl;
-   }
-
-   // Called after a test ends.
-   virtual void OnTestEnd(const ::testing::TestInfo& test_info)
-   {
-      int rank=CommunicatorType::GetRank(CommunicatorType::AllGroup);
-      sout << test_info.test_case_name() << "." << test_info.name() << " End." <<std::endl;
-      std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-      sout.str( std::string() );
-      sout.clear();
-   }
-};
-#endif
-
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-   #ifdef HAVE_MPI
-      ::testing::TestEventListeners& listeners =
-         ::testing::UnitTest::GetInstance()->listeners();
-
-      delete listeners.Release(listeners.default_result_printer());
-      listeners.Append(new MinimalistBufferedPrinter);
-
-      Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-   #endif
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main_mpi.h"
diff --git a/src/UnitTests/Matrices/SparseMatrixCopyTest.h b/src/UnitTests/Matrices/SparseMatrixCopyTest.h
index 2885bac093d8a3e59144535baf892f27ef0cc24e..a38f294979cf47f336908424405383f426257319 100644
--- a/src/UnitTests/Matrices/SparseMatrixCopyTest.h
+++ b/src/UnitTests/Matrices/SparseMatrixCopyTest.h
@@ -551,13 +551,4 @@ TEST( SparseMatrixCopyTest, SlicedEllpack_to_Ellpack_cuda )
 
 #endif
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Matrices/SparseMatrixTest.h b/src/UnitTests/Matrices/SparseMatrixTest.h
index 78121bdf2af3f278b936e71c75225e17efe53073..c3716c116fedbcb3ba5f90a48039298d06c5b09c 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest.h
+++ b/src/UnitTests/Matrices/SparseMatrixTest.h
@@ -50,13 +50,4 @@ TEST( SparseMatrixTest, CSR_perforSORIterationTest_Cuda )
 
 #endif
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Matrices/SparseMatrixTest_AdEllpack.h b/src/UnitTests/Matrices/SparseMatrixTest_AdEllpack.h
index 24b4db1b2d14cf744232c78aab3f1c6dceb8b402..f6ab325b03b4f989993d58c1cb27f9e3cad38c71 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest_AdEllpack.h
+++ b/src/UnitTests/Matrices/SparseMatrixTest_AdEllpack.h
@@ -139,13 +139,4 @@ TYPED_TEST( AdEllpackMatrixTest, printTest )
 #endif
 
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Matrices/SparseMatrixTest_BiEllpack.h b/src/UnitTests/Matrices/SparseMatrixTest_BiEllpack.h
index a18e7cc52c266db532949abe8b41a14048196c8e..c3dd6abb4e372ff70184075fcb243fd22e3c4cd8 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest_BiEllpack.h
+++ b/src/UnitTests/Matrices/SparseMatrixTest_BiEllpack.h
@@ -138,13 +138,4 @@ TYPED_TEST( BiEllpackMatrixTest, printTest )
 
 #endif
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Matrices/SparseMatrixTest_CSR.h b/src/UnitTests/Matrices/SparseMatrixTest_CSR.h
index 2eaecc76e78cbbe7925dbab4f4572e2c3504253c..9707f6b8419ba98a3e5153b58ffaebd1d99718c9 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest_CSR.h
+++ b/src/UnitTests/Matrices/SparseMatrixTest_CSR.h
@@ -136,13 +136,4 @@ TYPED_TEST( CSRMatrixTest, printTest )
 
 #endif
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Matrices/SparseMatrixTest_ChunkedEllpack.h b/src/UnitTests/Matrices/SparseMatrixTest_ChunkedEllpack.h
index 99ad9f0b45ddef8f1e996f6dd08409498a807562..1845255d3ad5e6113cf00b4296e99ca840d25fdc 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest_ChunkedEllpack.h
+++ b/src/UnitTests/Matrices/SparseMatrixTest_ChunkedEllpack.h
@@ -141,13 +141,4 @@ TYPED_TEST( ChunkedEllpackMatrixTest, printTest )
 
 #endif
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Matrices/SparseMatrixTest_Ellpack.h b/src/UnitTests/Matrices/SparseMatrixTest_Ellpack.h
index c6ecd72b384eee16fb2ee3ee6fa0b558f775a1cd..f20208b7c525dd259549c6d6132582ecd7164654 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest_Ellpack.h
+++ b/src/UnitTests/Matrices/SparseMatrixTest_Ellpack.h
@@ -136,13 +136,4 @@ TYPED_TEST( EllpackMatrixTest, printTest )
 
 #endif
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Matrices/SparseMatrixTest_SlicedEllpack.h b/src/UnitTests/Matrices/SparseMatrixTest_SlicedEllpack.h
index 0fc1f59e2f7369adc793f3e2c7094f42288c7f39..5341847711ee9a9d5194fa17f7e8be57b6fb640c 100644
--- a/src/UnitTests/Matrices/SparseMatrixTest_SlicedEllpack.h
+++ b/src/UnitTests/Matrices/SparseMatrixTest_SlicedEllpack.h
@@ -136,13 +136,4 @@ TYPED_TEST( SlicedEllpackMatrixTest, printTest )
 
 #endif
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Meshes/BoundaryTagsTest.cpp b/src/UnitTests/Meshes/BoundaryTagsTest.cpp
index 274ef974b78a2c41fa27ca08654723778bb95f9b..c83e407526e93910c8d5a8f5213307a0895a021a 100644
--- a/src/UnitTests/Meshes/BoundaryTagsTest.cpp
+++ b/src/UnitTests/Meshes/BoundaryTagsTest.cpp
@@ -1,11 +1,2 @@
 #include "BoundaryTagsTest.h"
-
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   return EXIT_FAILURE;
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/CopyEntitiesTest.cpp b/src/UnitTests/Meshes/DistributedMeshes/CopyEntitiesTest.cpp
index 383f8328b3e1b11475cc19a955b180cea646246f..1f6ddf2c7ddc6ba8e6ad79730ceb42dc408c49ce 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/CopyEntitiesTest.cpp
+++ b/src/UnitTests/Meshes/DistributedMeshes/CopyEntitiesTest.cpp
@@ -224,14 +224,4 @@ TEST( CopyEntitiesTest, 3D )
 
 #endif
 
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
-
+#include "../../main.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/CutDistributedGridTest.cpp b/src/UnitTests/Meshes/DistributedMeshes/CutDistributedGridTest.cpp
index 587ec807ec0ad01515832f777cd444c5c9ac386a..54071032c5ceba47386286a7fd30c317859a8da3 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/CutDistributedGridTest.cpp
+++ b/src/UnitTests/Meshes/DistributedMeshes/CutDistributedGridTest.cpp
@@ -4,7 +4,6 @@
 #ifdef HAVE_MPI  
 
 #include <TNL/Communicators/MpiCommunicator.h>
-#include <TNL/Communicators/ScopedInitializer.h>
 #include <TNL/Meshes/DistributedMeshes/DistributedMesh.h>
 #include <TNL/Meshes/DistributedMeshes/SubdomainOverlapsGetter.h>
 
@@ -356,74 +355,8 @@ TEST(CutDistributedGirdTest_3D, IsNotDistributed_2D)
         EXPECT_FALSE(cutDistributedGrid.isDistributed()) << "Řez by neměl být distribuovaný";
     }
 }
-
-
-
-#else
-TEST(NoMPI, NoTest)
-{
-    ASSERT_TRUE(true) << ":-(";
-}
 #endif
 
 #endif
 
-
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-#include <sstream>
-
-  class MinimalistBufferedPrinter : public ::testing::EmptyTestEventListener {
-      
-  private:
-      std::stringstream sout;
-      
-  public:
-      
-    // Called before a test starts.
-    virtual void OnTestStart(const ::testing::TestInfo& test_info) {
-      sout<< test_info.test_case_name() <<"." << test_info.name() << " Start." <<std::endl;
-    }
-
-    // Called after a failed assertion or a SUCCEED() invocation.
-    virtual void OnTestPartResult(
-        const ::testing::TestPartResult& test_part_result) {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") 
-              << test_part_result.file_name() << " "
-              << test_part_result.line_number() <<std::endl
-              << test_part_result.summary() <<std::endl;
-    }
-
-    // Called after a test ends.
-    virtual void OnTestEnd(const ::testing::TestInfo& test_info) 
-    {
-        int rank=CommunicatorType::GetRank(CommunicatorType::AllGroup);
-        sout<< test_info.test_case_name() <<"." << test_info.name() << " End." <<std::endl;
-        std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-        sout.str( std::string() );
-        sout.clear();
-    }
-  };
-#endif
-
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-    #ifdef HAVE_MPI
-       ::testing::TestEventListeners& listeners =
-          ::testing::UnitTest::GetInstance()->listeners();
-
-       delete listeners.Release(listeners.default_result_printer());
-       listeners.Append(new MinimalistBufferedPrinter);
-
-       Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-    #endif
-       return RUN_ALL_TESTS();
-#else
-   
-   throw GtestMissingError();
-#endif
-}
-
+#include "../../main_mpi.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/CutDistributedMeshFunctionTest.cpp b/src/UnitTests/Meshes/DistributedMeshes/CutDistributedMeshFunctionTest.cpp
index caaf3f613e39a616da425b330799c6d12e817ae9..7a19611daeda32732f12d2f4dcd1f1cac793ed01 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/CutDistributedMeshFunctionTest.cpp
+++ b/src/UnitTests/Meshes/DistributedMeshes/CutDistributedMeshFunctionTest.cpp
@@ -6,7 +6,6 @@
 #include <TNL/Devices/Host.h> 
 #include <TNL/Functions/CutMeshFunction.h>
 #include <TNL/Communicators/MpiCommunicator.h>
-#include <TNL/Communicators/ScopedInitializer.h>
 #include <TNL/Meshes/DistributedMeshes/DistributedGridIO.h>
 #include <TNL/Meshes/DistributedMeshes/SubdomainOverlapsGetter.h>
 
@@ -639,74 +638,8 @@ TEST(CutDistributedMeshFunction, 3D_2_Save)
       }
   
 }
-
-
-
-#else
-TEST(NoMPI, NoTest)
-{
-    ASSERT_TRUE(true) << ":-(";
-}
-#endif
-
-#endif
-
-
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-#include <sstream>
-
-  class MinimalistBufferedPrinter : public ::testing::EmptyTestEventListener {
-      
-  private:
-      std::stringstream sout;
-      
-  public:
-      
-    // Called before a test starts.
-    virtual void OnTestStart(const ::testing::TestInfo& test_info) {
-      sout<< test_info.test_case_name() <<"." << test_info.name() << " Start." <<std::endl;
-    }
-
-    // Called after a failed assertion or a SUCCEED() invocation.
-    virtual void OnTestPartResult(
-        const ::testing::TestPartResult& test_part_result) {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") 
-              << test_part_result.file_name() << " "
-              << test_part_result.line_number() <<std::endl
-              << test_part_result.summary() <<std::endl;
-    }
-
-    // Called after a test ends.
-    virtual void OnTestEnd(const ::testing::TestInfo& test_info) 
-    {
-        int rank=CommunicatorType::GetRank(CommunicatorType::AllGroup);
-        sout<< test_info.test_case_name() <<"." << test_info.name() << " End." <<std::endl;
-        std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-        sout.str( std::string() );
-        sout.clear();
-    }
-  };
 #endif
 
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-    #ifdef HAVE_MPI
-       ::testing::TestEventListeners& listeners =
-          ::testing::UnitTest::GetInstance()->listeners();
-
-       delete listeners.Release(listeners.default_result_printer());
-       listeners.Append(new MinimalistBufferedPrinter);
-
-       Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-    #endif
-       return RUN_ALL_TESTS();
-#else
-   
-   throw GtestMissingError();
 #endif
-}
 
+#include "../../main_mpi.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/CutMeshFunctionTest.cpp b/src/UnitTests/Meshes/DistributedMeshes/CutMeshFunctionTest.cpp
index ce78b85680c69bba791d205661d918d1498ef3a0..854cdbda1e2dc8389b9cffeb8f85e0112fc7865a 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/CutMeshFunctionTest.cpp
+++ b/src/UnitTests/Meshes/DistributedMeshes/CutMeshFunctionTest.cpp
@@ -213,13 +213,4 @@ TEST(CutMeshFunction, 3D_2)
 
 #endif
 
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../../main.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/DirectionsTest.cpp b/src/UnitTests/Meshes/DistributedMeshes/DirectionsTest.cpp
index b772ecda067d8563a838ce92fadc1fc03b6984fe..bc1f94f8af0ab5fe74e55c5d288d3b41da82f443 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/DirectionsTest.cpp
+++ b/src/UnitTests/Meshes/DistributedMeshes/DirectionsTest.cpp
@@ -120,15 +120,4 @@ TEST(XYZ, 3D )
 
 #endif
 
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-       int result= RUN_ALL_TESTS();
-       return result;
-#else
-   
-   throw GtestMissingError();
-#endif
-}
+#include "../../main.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridIOTestBase.h b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridIOTestBase.h
index 537bcd9239ddde38785b4c462d4bf9d71c0537c7..cd4a155ef6a3d59bec66ac209030f7dc42bfae29 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridIOTestBase.h
+++ b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridIOTestBase.h
@@ -12,7 +12,6 @@
 #ifdef HAVE_MPI
 
 #include "DistributedGridIOTest.h"
-#include <TNL/Communicators/ScopedInitializer.h>
 
 TEST( DistributedGridIO, Save_1D )
 {
@@ -74,74 +73,10 @@ TEST( DistributedGridIO, Load_3D_GPU )
 {
     TestDistributedGridIO<3,Cuda>::TestLoad();
 }
-
-#endif
-
-#else
-TEST(NoMPI, NoTest)
-{
-    ASSERT_TRUE(true) << ":-(";
-}
 #endif
 
 #endif
 
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-#include <sstream>
-
-  class MinimalistBufferedPrinter : public ::testing::EmptyTestEventListener {
-      
-  private:
-      std::stringstream sout;
-      
-  public:
-      
-    // Called before a test starts.
-    virtual void OnTestStart(const ::testing::TestInfo& test_info) {
-      sout<< test_info.test_case_name() <<"." << test_info.name() << " Start." <<std::endl;
-    }
-
-    // Called after a failed assertion or a SUCCEED() invocation.
-    virtual void OnTestPartResult(
-        const ::testing::TestPartResult& test_part_result) {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") 
-              << test_part_result.file_name() << " "
-              << test_part_result.line_number() <<std::endl
-              << test_part_result.summary() <<std::endl;
-    }
-
-    // Called after a test ends.
-    virtual void OnTestEnd(const ::testing::TestInfo& test_info) 
-    {
-        int rank=CommunicatorType::GetRank(CommunicatorType::AllGroup);
-        sout<< test_info.test_case_name() <<"." << test_info.name() << " End." <<std::endl;
-        std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-        sout.str( std::string() );
-        sout.clear();
-    }
-  };
 #endif
 
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-    #ifdef HAVE_MPI
-       ::testing::TestEventListeners& listeners =
-          ::testing::UnitTest::GetInstance()->listeners();
-
-       delete listeners.Release(listeners.default_result_printer());
-       listeners.Append(new MinimalistBufferedPrinter);
-
-       Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-       CommunicatorType::setRedirection( false );
-       CommunicatorType::setupRedirection();
-    #endif
-       return RUN_ALL_TESTS();
-#else
-   
-   throw GtestMissingError();
-#endif
-}
+#include "../../main_mpi.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridIO_MPIIOTestBase.h b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridIO_MPIIOTestBase.h
index 4e3603a7a40c36cc04d247f52148f029868dcbdf..f84de9065bf3fc1258531e1f269a843c4135a3cc 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridIO_MPIIOTestBase.h
+++ b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridIO_MPIIOTestBase.h
@@ -10,7 +10,6 @@
 #ifdef HAVE_MPI
 
 #include "DistributedGridIO_MPIIOTest.h"
-#include <TNL/Communicators/ScopedInitializer.h>
 
 TEST( DistributedGridMPIIO, Save_1D )
 {
@@ -74,71 +73,8 @@ TEST( DistributedGridMPIIO, Load_3D )
     }
 #endif
 
-#else
-TEST(NoMPI, NoTest)
-{
-    ASSERT_TRUE(true) << ":-(";
-}
-#endif
-
 #endif
 
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-#include <sstream>
-
-  class MinimalistBufferedPrinter : public ::testing::EmptyTestEventListener {
-      
-  private:
-      std::stringstream sout;
-      
-  public:
-      
-    // Called before a test starts.
-    virtual void OnTestStart(const ::testing::TestInfo& test_info) {
-      sout<< test_info.test_case_name() <<"." << test_info.name() << " Start." <<std::endl;
-    }
-
-    // Called after a failed assertion or a SUCCEED() invocation.
-    virtual void OnTestPartResult(
-        const ::testing::TestPartResult& test_part_result) {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") 
-              << test_part_result.file_name() << " "
-              << test_part_result.line_number() <<std::endl
-              << test_part_result.summary() <<std::endl;
-    }
-
-    // Called after a test ends.
-    virtual void OnTestEnd(const ::testing::TestInfo& test_info) 
-    {
-        int rank=CommunicatorType::GetRank(CommunicatorType::AllGroup);
-        sout<< test_info.test_case_name() <<"." << test_info.name() << " End." <<std::endl;
-        std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-        sout.str( std::string() );
-        sout.clear();
-    }
-  };
 #endif
 
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-    #ifdef HAVE_MPI
-       ::testing::TestEventListeners& listeners =
-          ::testing::UnitTest::GetInstance()->listeners();
-
-       delete listeners.Release(listeners.default_result_printer());
-       listeners.Append(new MinimalistBufferedPrinter);
-
-       Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-       CommunicatorType::setRedirection( false );
-       CommunicatorType::setupRedirection();
-    #endif
-       return RUN_ALL_TESTS();
-#else
-   
-   throw GtestMissingError();
-#endif
-}
+#include "../../main_mpi.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_1D.cpp b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_1D.cpp
index 43af00161224122d7169c960f12a7d079764c0f3..1a5dcb8194ddcaf56e81fb3ce908506b38d34126 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_1D.cpp
+++ b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_1D.cpp
@@ -13,7 +13,6 @@
 #ifdef HAVE_MPI    
 
 #include <TNL/Communicators/MpiCommunicator.h>
-#include <TNL/Communicators/ScopedInitializer.h>
 #include <TNL/Functions/MeshFunction.h>
 #include <TNL/Meshes/DistributedMeshes/DistributedMesh.h>
 #include <TNL/Meshes/DistributedMeshes/SubdomainOverlapsGetter.h>
@@ -378,71 +377,8 @@ TEST_F(DistributedGridTest_1D, SynchronizePeriodicBoundariesLinearTest )
    if( rank == nproc - 1 )
       EXPECT_EQ( meshFunctionPtr->getValue(entity2), 0 ) << "Linear function Overlap error on right Edge.";
 }
-
-#else
-TEST(NoMPI, NoTest)
-{
-    ASSERT_TRUE(true) << ":-(";
-}
 #endif
 
 #endif
 
-
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-#include <sstream>
-
-  class MinimalistBufferedPrinter : public ::testing::EmptyTestEventListener {
-      
-  private:
-      std::stringstream sout;
-      
-  public:
-      
-    // Called before a test starts.
-    virtual void OnTestStart(const ::testing::TestInfo& test_info) {
-      sout<< test_info.test_case_name() <<"." << test_info.name() << " Start." <<std::endl;
-    }
-
-    // Called after a failed assertion or a SUCCEED() invocation.
-    virtual void OnTestPartResult(
-        const ::testing::TestPartResult& test_part_result) {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") 
-              << test_part_result.file_name() << " "
-              << test_part_result.line_number() <<std::endl
-              << test_part_result.summary() <<std::endl;
-    }
-
-    // Called after a test ends.
-    virtual void OnTestEnd(const ::testing::TestInfo& test_info) 
-    {
-		int rank=CommunicatorType::GetRank(CommunicatorType::AllGroup);
-        sout<< test_info.test_case_name() <<"." << test_info.name() << " End." <<std::endl;
-        std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-        sout.str( std::string() );
-        sout.clear();
-    }
-  };
-#endif
-
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-    #ifdef HAVE_MPI
-       ::testing::TestEventListeners& listeners =
-          ::testing::UnitTest::GetInstance()->listeners();
-
-       delete listeners.Release(listeners.default_result_printer());
-       listeners.Append(new MinimalistBufferedPrinter);
-
-       Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-    #endif
-       return RUN_ALL_TESTS();
-#else
-   
-   throw GtestMissingError();
-#endif
-}
+#include "../../main_mpi.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_2D.cpp b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_2D.cpp
index f5a0056de7acb66c237de39d7667e94c89b9ad42..2aaeaa06bec0458a5551eb075891cee686708ed9 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_2D.cpp
+++ b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_2D.cpp
@@ -15,7 +15,6 @@
 #include <TNL/Meshes/DistributedMeshes/DistributedMesh.h>
 #include <TNL/Functions/MeshFunction.h>
 #include <TNL/Communicators/MpiCommunicator.h>
-#include <TNL/Communicators/ScopedInitializer.h>
 #include <TNL/Meshes/DistributedMeshes/SubdomainOverlapsGetter.h>
 
 #include "../../Functions/Functions.h"
@@ -1017,73 +1016,8 @@ TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithInActiv
    }
 }
 */ 
-
-#else
-TEST(NoMPI, NoTest)
-{
-    ASSERT_TRUE(true) << ":-(";
-}
 #endif
 
 #endif
 
-
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-#include <sstream>
-
-  class MinimalistBufferedPrinter : public ::testing::EmptyTestEventListener {
-      
-  private:
-      std::stringstream sout;
-      
-  public:
-      
-    // Called before a test starts.
-    virtual void OnTestStart(const ::testing::TestInfo& test_info) {
-      sout<< test_info.test_case_name() <<"." << test_info.name() << " Start." <<std::endl;
-    }
-
-    // Called after a failed assertion or a SUCCEED() invocation.
-    virtual void OnTestPartResult(
-        const ::testing::TestPartResult& test_part_result) {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") 
-              << test_part_result.file_name() << " "
-              << test_part_result.line_number() <<std::endl
-              << test_part_result.summary() <<std::endl;
-    }
-
-    // Called after a test ends.
-    virtual void OnTestEnd(const ::testing::TestInfo& test_info) 
-    {
-        int rank=CommunicatorType::GetRank(CommunicatorType::AllGroup);
-        sout<< test_info.test_case_name() <<"." << test_info.name() << " End." <<std::endl;
-        std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-        sout.str( std::string() );
-        sout.clear();
-    }
-  };
-#endif
-
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-    #ifdef HAVE_MPI
-       ::testing::TestEventListeners& listeners =
-          ::testing::UnitTest::GetInstance()->listeners();
-
-       delete listeners.Release(listeners.default_result_printer());
-       listeners.Append(new MinimalistBufferedPrinter);
-
-       Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-    #endif
-       return RUN_ALL_TESTS();
-#else
-   
-   throw GtestMissingError();
-#endif
-}
-
-
+#include "../../main_mpi.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_3D.cpp b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_3D.cpp
index f92ef08d7a58fb053541ae5f6b5e2b4dc75560a0..823c30db928996ca16e569d55609b9d6553d5142 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_3D.cpp
+++ b/src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_3D.cpp
@@ -4,7 +4,6 @@
 #ifdef HAVE_MPI    
 
 #include <TNL/Communicators/MpiCommunicator.h>
-#include <TNL/Communicators/ScopedInitializer.h>
 #include <TNL/Functions/MeshFunction.h>
 #include <TNL/Meshes/DistributedMeshes/DistributedMesh.h>
 #include <TNL/Meshes/DistributedMeshes/SubdomainOverlapsGetter.h>
@@ -720,75 +719,8 @@ TEST_F(DistributedGirdTest_3D, SynchronizerNeighborTest)
 
 }
 */
-
-#else
-TEST(NoMPI, NoTest)
-{
-    ASSERT_TRUE(true) << ":-(";
-}
-#endif
-
-#endif
-
-
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-#include <sstream>
-
-  class MinimalistBufferedPrinter : public ::testing::EmptyTestEventListener {
-      
-  private:
-      std::stringstream sout;
-      
-  public:
-      
-    // Called before a test starts.
-    virtual void OnTestStart(const ::testing::TestInfo& test_info) {
-      sout<< test_info.test_case_name() <<"." << test_info.name() << " Start." <<std::endl;
-    }
-
-    // Called after a failed assertion or a SUCCEED() invocation.
-    virtual void OnTestPartResult(
-        const ::testing::TestPartResult& test_part_result) {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") 
-              << test_part_result.file_name() << " "
-              << test_part_result.line_number() <<std::endl
-              << test_part_result.summary() <<std::endl;
-    }
-
-    // Called after a test ends.
-    virtual void OnTestEnd(const ::testing::TestInfo& test_info) 
-    {
-        int rank=CommunicatorType::GetRank(CommunicatorType::AllGroup);
-        sout<< test_info.test_case_name() <<"." << test_info.name() << " End." <<std::endl;
-        std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-        sout.str( std::string() );
-        sout.clear();
-    }
-  };
 #endif
 
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-    #ifdef HAVE_MPI
-       ::testing::TestEventListeners& listeners =
-          ::testing::UnitTest::GetInstance()->listeners();
-
-       delete listeners.Release(listeners.default_result_printer());
-       listeners.Append(new MinimalistBufferedPrinter);
-
-       Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-    #endif
-       return RUN_ALL_TESTS();
-#else
-   
-   throw GtestMissingError();
 #endif
-}
-
-
-
 
+#include "../../main_mpi.h"
diff --git a/src/UnitTests/Meshes/DistributedMeshes/DistributedVectorFieldIO_MPIIOTest.cpp b/src/UnitTests/Meshes/DistributedMeshes/DistributedVectorFieldIO_MPIIOTest.cpp
index 67098fc5db6c801410425378ab5b609778b376f3..0a5ab3e37da3c3f0360fad0525425df95d2d6c9e 100644
--- a/src/UnitTests/Meshes/DistributedMeshes/DistributedVectorFieldIO_MPIIOTest.cpp
+++ b/src/UnitTests/Meshes/DistributedMeshes/DistributedVectorFieldIO_MPIIOTest.cpp
@@ -1,12 +1,8 @@
-
-
-
 #ifdef HAVE_GTEST
       #include <gtest/gtest.h>
 #ifdef HAVE_MPI
 
 #include <TNL/Communicators/MpiCommunicator.h>
-#include <TNL/Communicators/ScopedInitializer.h>
 #include "DistributedVectorFieldIO_MPIIOTestBase.h"
 
 using namespace TNL::Communicators;
@@ -43,73 +39,8 @@ TEST( DistributedVectorFieldIO_MPIIO, Load_3D )
 {
     TestDistributedVectorFieldMPIIO<3,2,Host>::TestLoad();
 }
-
-
-#else
-TEST(NoMPI, NoTest)
-{
-    ASSERT_TRUE(true) << ":-(";
-}
 #endif
 
 #endif
 
-#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
-#include <sstream>
-
-  class MinimalistBufferedPrinter : public ::testing::EmptyTestEventListener {
-      
-  private:
-      std::stringstream sout;
-      
-  public:
-      
-    // Called before a test starts.
-    virtual void OnTestStart(const ::testing::TestInfo& test_info) {
-      sout<< test_info.test_case_name() <<"." << test_info.name() << " Start." <<std::endl;
-    }
-
-    // Called after a failed assertion or a SUCCEED() invocation.
-    virtual void OnTestPartResult(
-        const ::testing::TestPartResult& test_part_result) {
-      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ") 
-              << test_part_result.file_name() << " "
-              << test_part_result.line_number() <<std::endl
-              << test_part_result.summary() <<std::endl;
-    }
-
-    // Called after a test ends.
-    virtual void OnTestEnd(const ::testing::TestInfo& test_info) 
-    {
-        int rank=CommunicatorType::GetRank(CommunicatorType::AllGroup);
-        sout<< test_info.test_case_name() <<"." << test_info.name() << " End." <<std::endl;
-        std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
-        sout.str( std::string() );
-        sout.clear();
-    }
-  };
-#endif
-
-#include "../../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-
-    #ifdef HAVE_MPI
-       ::testing::TestEventListeners& listeners =
-          ::testing::UnitTest::GetInstance()->listeners();
-
-       delete listeners.Release(listeners.default_result_printer());
-       listeners.Append(new MinimalistBufferedPrinter);
-
-       Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
-       CommunicatorType::setRedirection( false );
-       CommunicatorType::setupRedirection();
-    #endif
-       return RUN_ALL_TESTS();
-#else
-   
-   throw GtestMissingError();
-#endif
-}
+#include "../../main_mpi.h"
diff --git a/src/UnitTests/Meshes/MeshEntityTest.cpp b/src/UnitTests/Meshes/MeshEntityTest.cpp
index e3f87a32bf81d05898c1451dc88488b71df8dc31..66b6da128f164951b07c6feff55f740dd9c3b988 100644
--- a/src/UnitTests/Meshes/MeshEntityTest.cpp
+++ b/src/UnitTests/Meshes/MeshEntityTest.cpp
@@ -1,11 +1,2 @@
 #include "MeshEntityTest.h"
-
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   return EXIT_FAILURE;
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Meshes/MeshOrderingTest.cpp b/src/UnitTests/Meshes/MeshOrderingTest.cpp
index fc03c92cc71ee9d8fa3ca554651e20ff19b170c2..ff02fe8a2c73f643745873432cd06c3cdaf87e66 100644
--- a/src/UnitTests/Meshes/MeshOrderingTest.cpp
+++ b/src/UnitTests/Meshes/MeshOrderingTest.cpp
@@ -1,11 +1,2 @@
 #include "MeshOrderingTest.h"
-
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   return EXIT_FAILURE;
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Meshes/MeshOrderingTest.cu b/src/UnitTests/Meshes/MeshOrderingTest.cu
index fc03c92cc71ee9d8fa3ca554651e20ff19b170c2..ff02fe8a2c73f643745873432cd06c3cdaf87e66 100644
--- a/src/UnitTests/Meshes/MeshOrderingTest.cu
+++ b/src/UnitTests/Meshes/MeshOrderingTest.cu
@@ -1,11 +1,2 @@
 #include "MeshOrderingTest.h"
-
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   return EXIT_FAILURE;
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Meshes/MeshTest.cpp b/src/UnitTests/Meshes/MeshTest.cpp
index 93004f18d5245073d8d6811c1253acfd6cf7a509..d0ee1e52f4a097d3fdd526dc04f1d855e430d4eb 100644
--- a/src/UnitTests/Meshes/MeshTest.cpp
+++ b/src/UnitTests/Meshes/MeshTest.cpp
@@ -1,11 +1,2 @@
 #include "MeshTest.h"
-
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   return EXIT_FAILURE;
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Meshes/MeshTest.cu b/src/UnitTests/Meshes/MeshTest.cu
index 93004f18d5245073d8d6811c1253acfd6cf7a509..d0ee1e52f4a097d3fdd526dc04f1d855e430d4eb 100644
--- a/src/UnitTests/Meshes/MeshTest.cu
+++ b/src/UnitTests/Meshes/MeshTest.cu
@@ -1,11 +1,2 @@
 #include "MeshTest.h"
-
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   return EXIT_FAILURE;
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/ObjectTest.cpp b/src/UnitTests/ObjectTest.cpp
index 8de41750784e68be25bf47211c913d72b63c67e1..be30000b200c1d3c766970f8d66c8f32fcdfbe4f 100644
--- a/src/UnitTests/ObjectTest.cpp
+++ b/src/UnitTests/ObjectTest.cpp
@@ -91,18 +91,6 @@ TEST( HeaderTest, SaveAndLoadTest )
 
    EXPECT_EQ( std::remove( "test-file.tnl" ), 0 );
 }
-
-
 #endif
 
-
-#include "GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "main.h"
diff --git a/src/UnitTests/Pointers/SharedPointerCudaTest.cu b/src/UnitTests/Pointers/SharedPointerCudaTest.cu
index 813054c140fc9ec7aa07784adf596670d5d17c40..c0d76b2cc050d074831a4a6065d71b99ea24a7e9 100644
--- a/src/UnitTests/Pointers/SharedPointerCudaTest.cu
+++ b/src/UnitTests/Pointers/SharedPointerCudaTest.cu
@@ -14,12 +14,11 @@
 #include <TNL/Containers/StaticArray.h>
 #include <TNL/Containers/Array.h>
 
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 #include <gtest/gtest.h>
 #endif
 
 #include <TNL/Devices/Cuda.h>
-#include "../GtestMissingError.h"
 
 using namespace TNL;
 
@@ -50,18 +49,18 @@ TEST( SharedPointerCudaTest, getDataTest )
 #ifdef HAVE_CUDA
    typedef TNL::Containers::StaticArray< 2, int  > TestType;
    Pointers::SharedPointer< TestType, Devices::Cuda > ptr1( 1, 2 );
-   
+
 #ifdef HAVE_CUDA_UNIFIED_MEMORY
    ASSERT_EQ( ptr1->x(), 1 );
    ASSERT_EQ( ptr1->y(), 2 );
 #else
-   
+
    Devices::Cuda::synchronizeDevice();
-   
+
    TestType aux;
-   
+
    cudaMemcpy( ( void*) &aux, &ptr1.getData< Devices::Cuda >(), sizeof( TestType ), cudaMemcpyDeviceToHost );
-   
+
    ASSERT_EQ( aux[ 0 ], 1 );
    ASSERT_EQ( aux[ 1 ], 2 );
 #endif  // HAVE_CUDA_UNIFIED_MEMORY
@@ -85,7 +84,7 @@ TEST( SharedPointerCudaTest, getDataArrayTest )
 #ifdef HAVE_CUDA
    typedef TNL::Containers::Array< int, Devices::Cuda  > TestType;
    Pointers::SharedPointer< TestType > ptr;
-   
+
    ptr->setSize( 2 );
    ptr->setElement( 0, 1 );
    ptr->setElement( 1, 2 );
@@ -97,10 +96,10 @@ TEST( SharedPointerCudaTest, getDataArrayTest )
    copyArrayKernel<<< 1, 2 >>>( &ptr.getData< Devices::Cuda >(), testArray_device );
    testArray_host = new int [ 2 ];
    cudaMemcpy( testArray_host, testArray_device, 2 * sizeof( int ), cudaMemcpyDeviceToHost );
-   
+
    ASSERT_EQ( testArray_host[ 0 ], 1 );
    ASSERT_EQ( testArray_host[ 1 ], 2 );
-   
+
    delete[] testArray_host;
    cudaFree( testArray_device );
 
@@ -112,10 +111,10 @@ TEST( SharedPointerCudaTest, nullptrAssignement )
 #ifdef HAVE_CUDA
    using TestType = Pointers::SharedPointer< double, Devices::Cuda >;
    TestType p1( 5 ), p2( nullptr );
-   
+
    // This should not crash
    p1 = p2;
-   
+
    ASSERT_FALSE( p1 );
    ASSERT_FALSE( p2 );
 #endif
@@ -126,23 +125,15 @@ TEST( SharedPointerCudaTest, swap )
 #ifdef HAVE_CUDA
    using TestType = Pointers::SharedPointer< double, Devices::Cuda >;
    TestType p1( 1 ), p2( 2 );
-   
+
    p1.swap( p2 );
-   
+
    ASSERT_EQ( *p1, 2 );
    ASSERT_EQ( *p2, 1 );
 #endif
 }
 
-
 #endif
 
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+
+#include "../main.h"
diff --git a/src/UnitTests/Pointers/SharedPointerHostTest.cpp b/src/UnitTests/Pointers/SharedPointerHostTest.cpp
index b7d441f70e8e714cd911ae27d8e3a6a92204277e..53501e774b784b73dc7d73df2b1e063b70acd1da 100644
--- a/src/UnitTests/Pointers/SharedPointerHostTest.cpp
+++ b/src/UnitTests/Pointers/SharedPointerHostTest.cpp
@@ -13,13 +13,13 @@
 #include <TNL/Pointers/SharedPointer.h>
 #include <TNL/Containers/StaticArray.h>
 
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 #include <gtest/gtest.h>
 #endif
 
 using namespace TNL;
 
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 TEST( SharedPointerHostTest, ConstructorTest )
 {
    typedef TNL::Containers::StaticArray< 2, int  > TestType;
@@ -43,10 +43,10 @@ TEST( SharedPointerCudaTest, nullptrAssignement )
 {
    using TestType = Pointers::SharedPointer< double, Devices::Host >;
    TestType p1( 5 ), p2( nullptr );
-   
+
    // This should not crash
    p1 = p2;
-   
+
    ASSERT_FALSE( p1 );
    ASSERT_FALSE( p2 );
 }
@@ -55,22 +55,12 @@ TEST( SharedPointerCudaTest, swap )
 {
    using TestType = Pointers::SharedPointer< double, Devices::Host >;
    TestType p1( 1 ), p2( 2 );
-   
+
    p1.swap( p2 );
-   
+
    ASSERT_EQ( *p1, 2 );
    ASSERT_EQ( *p2, 1 );
 }
-
 #endif
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/Pointers/UniquePointerTest.cpp b/src/UnitTests/Pointers/UniquePointerTest.cpp
index 2fba352f588ed01a9369598f8cdfcd8506dc6a97..4473580171c087264e608dd611e7ebff66c10300 100644
--- a/src/UnitTests/Pointers/UniquePointerTest.cpp
+++ b/src/UnitTests/Pointers/UniquePointerTest.cpp
@@ -13,14 +13,14 @@
 #include <TNL/Pointers/UniquePointer.h>
 #include <TNL/Containers/StaticArray.h>
 
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 #include <gtest/gtest.h>
 #endif
 
 using namespace TNL;
 using namespace TNL::Pointers;
 
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 TEST( UniquePointerTest, ConstructorTest )
 {
    typedef TNL::Containers::StaticArray< 2, int  > TestType;
@@ -41,13 +41,4 @@ TEST( UniquePointerTest, ConstructorTest )
 };
 #endif
 
-#include "../GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
+#include "../main.h"
diff --git a/src/UnitTests/SaveAndLoadMeshfunctionTest.cpp b/src/UnitTests/SaveAndLoadMeshfunctionTest.cpp
index 9e4b1eaf36bf9f00672ec1de4a0b01b0c8378ca5..1596fbcfbe93e4e2b2fe15faa457e72b0ade0375 100644
--- a/src/UnitTests/SaveAndLoadMeshfunctionTest.cpp
+++ b/src/UnitTests/SaveAndLoadMeshfunctionTest.cpp
@@ -108,18 +108,6 @@ TEST( CopyEntitiesTest, 3D )
 {
     TestSaveAndLoadMeshfunction<3>::Test();
 }
-
-
 #endif
 
-#include "GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
-
+#include "main.h"
diff --git a/src/UnitTests/StringTest.cpp b/src/UnitTests/StringTest.cpp
index 755cb6419db46526980d22ef45949d6f669d8f06..099bc4d6c4c344fcd86c4cb76159a9fc88585154 100644
--- a/src/UnitTests/StringTest.cpp
+++ b/src/UnitTests/StringTest.cpp
@@ -316,17 +316,6 @@ TEST( StringTest, SaveLoad )
 
    EXPECT_EQ( std::remove( "test-file.tnl" ), 0 );
 };
-
-#endif
-
-#include "GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
 #endif
-}
 
+#include "main.h"
diff --git a/src/UnitTests/TimerTest.cpp b/src/UnitTests/TimerTest.cpp
index 6c20c4abb2bf6bbd6216db9feeaea7ef06d72d6e..dd46f30f3c120cbd6ac390a6c9856826b13ea6fa 100644
--- a/src/UnitTests/TimerTest.cpp
+++ b/src/UnitTests/TimerTest.cpp
@@ -10,7 +10,7 @@
 
 // Implemented by Nina Dzugasova
 
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 #include <gtest/gtest.h>
 #endif
 
@@ -18,7 +18,7 @@
 
 using namespace TNL;
 
-#ifdef HAVE_GTEST 
+#ifdef HAVE_GTEST
 TEST( TimerTest, Constructor )
 {
     Timer time;
@@ -34,16 +34,4 @@ TEST( TimerTest, Constructor )
 }
 #endif
 
-
-#include "GtestMissingError.h"
-int main( int argc, char* argv[] )
-{
-#ifdef HAVE_GTEST
-   ::testing::InitGoogleTest( &argc, argv );
-   return RUN_ALL_TESTS();
-#else
-   throw GtestMissingError();
-#endif
-}
-
-
+#include "main.h"
diff --git a/src/UnitTests/main.h b/src/UnitTests/main.h
new file mode 100644
index 0000000000000000000000000000000000000000..87da37fa894a7e0bced5dff59a26189e8f003e14
--- /dev/null
+++ b/src/UnitTests/main.h
@@ -0,0 +1,15 @@
+#ifdef HAVE_GTEST
+#include <gtest/gtest.h>
+#else
+#include "GtestMissingError.h"
+#endif
+
+int main( int argc, char* argv[] )
+{
+#ifdef HAVE_GTEST
+   ::testing::InitGoogleTest( &argc, argv );
+   return RUN_ALL_TESTS();
+#else
+   throw GtestMissingError();
+#endif
+}
diff --git a/src/UnitTests/main_mpi.h b/src/UnitTests/main_mpi.h
new file mode 100644
index 0000000000000000000000000000000000000000..3c7c39a86f87f695f3ea00d099c66f36d2fd579a
--- /dev/null
+++ b/src/UnitTests/main_mpi.h
@@ -0,0 +1,66 @@
+#ifdef HAVE_GTEST
+#include <gtest/gtest.h>
+#else
+#include "GtestMissingError.h"
+#endif
+
+#if (defined(HAVE_GTEST) && defined(HAVE_MPI))
+#include <TNL/Communicators/MpiCommunicator.h>
+#include <TNL/Communicators/ScopedInitializer.h>
+using CommunicatorType = Communicators::MpiCommunicator;
+
+#include <sstream>
+
+class MinimalistBufferedPrinter
+: public ::testing::EmptyTestEventListener
+{
+private:
+   std::stringstream sout;
+
+public:
+   // Called before a test starts.
+   virtual void OnTestStart(const ::testing::TestInfo& test_info)
+   {
+      sout << test_info.test_case_name() << "." << test_info.name() << " Start." << std::endl;
+   }
+
+   // Called after a failed assertion or a SUCCEED() invocation.
+   virtual void OnTestPartResult(const ::testing::TestPartResult& test_part_result)
+   {
+      sout << (test_part_result.failed() ? "====Failure=== " : "===Success=== ")
+           << test_part_result.file_name() << " "
+           << test_part_result.line_number() <<std::endl
+           << test_part_result.summary() <<std::endl;
+   }
+
+   // Called after a test ends.
+   virtual void OnTestEnd(const ::testing::TestInfo& test_info)
+   {
+      const int rank = CommunicatorType::GetRank(CommunicatorType::AllGroup);
+      sout << test_info.test_case_name() << "." << test_info.name() << " End." <<std::endl;
+      std::cout << rank << ":" << std::endl << sout.str()<< std::endl;
+      sout.str( std::string() );
+      sout.clear();
+   }
+};
+#endif
+
+int main( int argc, char* argv[] )
+{
+#ifdef HAVE_GTEST
+   ::testing::InitGoogleTest( &argc, argv );
+
+   #ifdef HAVE_MPI
+      ::testing::TestEventListeners& listeners =
+         ::testing::UnitTest::GetInstance()->listeners();
+
+      delete listeners.Release(listeners.default_result_printer());
+      listeners.Append(new MinimalistBufferedPrinter);
+
+      Communicators::ScopedInitializer< CommunicatorType > mpi(argc, argv);
+   #endif
+   return RUN_ALL_TESTS();
+#else
+   throw GtestMissingError();
+#endif
+}