diff --git a/sflphone-common/test/historytest.cpp b/sflphone-common/test/historytest.cpp
index babe871c93187cc15d04e8229530d2fd05748030..f8efbee22d7416f1f12feafbb3e3fd7ed0a39b21 100644
--- a/sflphone-common/test/historytest.cpp
+++ b/sflphone-common/test/historytest.cpp
@@ -30,6 +30,7 @@
 
 #include <stdio.h>
 #include <sstream>
+#include <cstdlib>
 
 #include "historytest.h"
 #include "manager.h"
@@ -41,6 +42,7 @@ using std::endl;
 
 void HistoryTest::setUp()
 {
+    system("cp " HISTORY_SAMPLE " " HISTORY_SAMPLE ".bak");
     // Instanciate the cleaner singleton
     history = new HistoryManager();
 }
@@ -51,11 +53,7 @@ void HistoryTest::test_create_history_path()
     _debug ("-------------------- HistoryTest::test_create_history_path --------------------\n");
 
     int result;
-    char *cpath;
-    std::string path;
-
-    cpath = getenv ("XDG_DATA_HOME");
-    (cpath != NULL) ? path = std::string (cpath) : path = std::string ("/") + HISTORY_SAMPLE;
+    std::string path(HISTORY_SAMPLE);
 
     result = history->create_history_path(path);
     CPPUNIT_ASSERT (result == 0);
@@ -228,4 +226,5 @@ void HistoryTest::tearDown()
     // Delete the history object
     delete history;
     history = 0;
+    system("mv " HISTORY_SAMPLE ".bak " HISTORY_SAMPLE);
 }
diff --git a/sflphone-common/test/main.cpp b/sflphone-common/test/main.cpp
index ed843d847072480ca5203c57d5eb16e927ddc510..3a7af6754b06002720721196e66b5931e15f83ba 100644
--- a/sflphone-common/test/main.cpp
+++ b/sflphone-common/test/main.cpp
@@ -32,6 +32,8 @@
 #include <manager.h>
 #include <constants.h>
 
+#include <cstdlib>
+
 #include <cppunit/CompilerOutputter.h>
 #include <cppunit/XmlOutputter.h>
 #include <cppunit/extensions/TestFactoryRegistry.h>
@@ -39,7 +41,6 @@
 
 int main (int argc, char* argv[])
 {
-
     printf ("\nSFLphone Daemon Test Suite, by Savoir-Faire Linux 2004-2010\n\n");
     Logger::setConsoleLog (true);
     Logger::setDebugMode (true);
@@ -65,7 +66,7 @@ int main (int argc, char* argv[])
                 printf (" - %s\n", suite->getChildTestAt (i)->getName().c_str());
             }
 
-            exit (0);
+            return 0;
         } else if (strcmp ("--debug", argv[1]) == 0) {
             argvIndex++;
 
@@ -89,6 +90,7 @@ int main (int argc, char* argv[])
     }
 
     printf ("\n\n=== SFLphone initialization ===\n\n");
+    system("cp " CONFIG_SAMPLE " " CONFIG_SAMPLE ".bak");
     Manager::instance().initConfigFile (true, CONFIG_SAMPLE);
     Manager::instance().init();
 
@@ -98,7 +100,8 @@ int main (int argc, char* argv[])
 
     if (suite->getChildTestCount() == 0) {
         _error ("Invalid test suite name: %s", testSuiteName.c_str());
-        exit (-1);
+        system("mv " CONFIG_SAMPLE ".bak " CONFIG_SAMPLE);
+        return 1;
     }
 
     // Adds the test to the list of test to run
@@ -120,6 +123,7 @@ int main (int argc, char* argv[])
 
     Manager::instance().terminate();
 
-    // Return error code 1 if the one of test failed.
+    system("mv " CONFIG_SAMPLE ".bak " CONFIG_SAMPLE);
+
     return wasSucessful ? 0 : 1;
 }