diff --git a/hudson-sflphone-script.sh b/hudson-sflphone-script.sh
index 3cd75ab50037d7aeb13c501948e496f28c7f4cf1..a0b1ab68d1b99426cbeb8205cf90c1430f27b126 100755
--- a/hudson-sflphone-script.sh
+++ b/hudson-sflphone-script.sh
@@ -29,7 +29,7 @@ pushd sflphone-common/test
 rm -rf $XML_RESULTS
 make check
 # if at least one test failed, exit
-./test --xml || exit 1
+CODECS_PATH="../src/audio/codecs" FAKE_PLUGIN_DIR="../src/plug-in/test/" FAKE_PLUGIN_NAME="../src/plug-in/test/libplugintest.so" ./test --xml || exit 1
 popd
 
 # Compile the client
diff --git a/sflphone-common/src/audio/codecs/audiocodecfactory.cpp b/sflphone-common/src/audio/codecs/audiocodecfactory.cpp
index e751d1cab51c1576cd592a900e74ee021d8cbe15..2dc459c41f762db96482334321b302de0886d608 100644
--- a/sflphone-common/src/audio/codecs/audiocodecfactory.cpp
+++ b/sflphone-common/src/audio/codecs/audiocodecfactory.cpp
@@ -192,9 +192,13 @@ std::vector<sfl::Codec*> AudioCodecFactory::scanCodecDirectory (void)
 
     std::string libDir = std::string (CODECS_DIR).append ("/");
     std::string homeDir = std::string (HOMEDIR)  + DIR_SEPARATOR_STR + "." + PROGDIR + "/";
+    // look for a CODECS_PATH environment variable...used in tests
+    const char *envDir = getenv("CODECS_PATH");
     std::vector<std::string> dirToScan;
     dirToScan.push_back (homeDir);
     dirToScan.push_back (libDir);
+    if (envDir)
+        dirToScan.push_back(std::string(envDir) + DIR_SEPARATOR_STR);
 
     for (i = 0 ; (unsigned int) i < dirToScan.size() ; i++) {
         std::string dirStr = dirToScan[i];
diff --git a/sflphone-common/src/plug-in/pluginmanager.cpp b/sflphone-common/src/plug-in/pluginmanager.cpp
index 92027908a9a49eb16bc48ab1d24e73422ae87630..4789973859aeae904c9a0a3f3ba036d18dd92c83 100644
--- a/sflphone-common/src/plug-in/pluginmanager.cpp
+++ b/sflphone-common/src/plug-in/pluginmanager.cpp
@@ -56,6 +56,15 @@ PluginManager::~PluginManager()
     _instance = 0;
 }
 
+namespace {
+bool hasSharedExtension(const std::string &fn)
+{
+    size_t dot_position = fn.rfind(".");
+    return (dot_position != std::string::npos and
+            fn.substr(dot_position) == ".so");
+}
+}
+
 int
 PluginManager::loadPlugins (const std::string &path)
 {
@@ -69,7 +78,10 @@ PluginManager::loadPlugins (const std::string &path)
     const std::string cDir = ".";
 
     /* The directory in which plugins are dropped. Default: /usr/lib/sflphone/plugins/ */
-    (path == "") ? pluginDir = std::string (PLUGINS_DIR).append ("/") :pluginDir = path;
+    if (path.empty())
+        pluginDir = std::string (PLUGINS_DIR).append("/");
+    else
+        pluginDir = path;
     _debug ("Loading plugins from %s...", pluginDir.c_str());
 
     dir = opendir (pluginDir.c_str());
@@ -80,9 +92,9 @@ PluginManager::loadPlugins (const std::string &path)
         while ( (dirStruct=readdir (dir))) {
             /* Get the name of the current item in the directory */
             current = dirStruct->d_name;
-            /* Test if the current item is not the parent or the current directory */
+            /* Test if the current item is not the parent or the current directory and that it ends with .so*/
 
-            if (current != pDir && current != cDir) {
+            if (current != pDir && current != cDir and hasSharedExtension(current)) {
 
                 /* Load the dynamic library */
                 library = loadDynamicLibrary (pluginDir + current);
diff --git a/sflphone-common/test/Makefile.am b/sflphone-common/test/Makefile.am
index 42741e2b361b03c89d7c8bed0c15e9935a852112..e62c988530a4f827fe03e1de6d1140924fcb1b50 100644
--- a/sflphone-common/test/Makefile.am
+++ b/sflphone-common/test/Makefile.am
@@ -1,5 +1,8 @@
 include ../globals.mak
 
+TESTS_ENVIRONMENT = CODECS_PATH="$(top_builddir)/src/audio/codecs" \
+					FAKE_PLUGIN_DIR="$(top_builddir)/src/plug-in/test/" \
+					FAKE_PLUGIN_NAME="$(top_builddir)/src/plug-in/test/libplugintest.so"
 check_PROGRAMS = test
 
 test_CXXFLAGS = $(CPPUNIT_CFLAGS)
diff --git a/sflphone-common/test/pluginmanagertest.cpp b/sflphone-common/test/pluginmanagertest.cpp
index 9182dab99a2afa91a27338fff6df4c930d4b288e..cffbf4c3bbaa7bcfe5285242b9a5fd5229f407e0 100644
--- a/sflphone-common/test/pluginmanagertest.cpp
+++ b/sflphone-common/test/pluginmanagertest.cpp
@@ -37,13 +37,13 @@
 using std::cout;
 using std::endl;
 
-#define PLUGIN_TEST_DIR  "/usr/lib/sflphone/plugins/"
-#define PLUGIN_TEST_DESC  "mytest"
-#define PLUGIN_TEST_NAME  "/usr/lib/sflphone/plugins/libplugintest.so"
+#define FAKE_PLUGIN_DESC  "mytest"
 
 
 void PluginManagerTest::setUp()
 {
+    FAKE_PLUGIN_DIR = std::string(getenv("FAKE_PLUGIN_DIR"));
+    FAKE_PLUGIN_NAME =  std::string(getenv("FAKE_PLUGIN_NAME"));
     // Instanciate the plugin manager singleton
     _pm = PluginManager::instance();
     library = 0;
@@ -54,14 +54,14 @@ void PluginManagerTest::testLoadDynamicLibrary()
 {
     _debug ("-------------------- PluginManagerTest::testLoadDynamicLibrary --------------------\n");
 
-    CPPUNIT_ASSERT (_pm->loadDynamicLibrary (PLUGIN_TEST_NAME) != NULL);
+    CPPUNIT_ASSERT (_pm->loadDynamicLibrary (FAKE_PLUGIN_NAME) != NULL);
 }
 
 void PluginManagerTest::testUnloadDynamicLibrary()
 {
     _debug ("-------------------- PluginManagerTest::testUnloadDynamicLibrary --------------------\n");
 
-    library = _pm->loadDynamicLibrary (PLUGIN_TEST_NAME);
+    library = _pm->loadDynamicLibrary (FAKE_PLUGIN_NAME);
     CPPUNIT_ASSERT (library != NULL);
     CPPUNIT_ASSERT (_pm->unloadDynamicLibrary (library) == 0);
 }
@@ -70,7 +70,7 @@ void PluginManagerTest::testInstanciatePlugin()
 {
     _debug ("-------------------- PluginManagerTest::testInstanciatePlugin --------------------\n");
 
-    library = _pm->loadDynamicLibrary (PLUGIN_TEST_NAME);
+    library = _pm->loadDynamicLibrary (FAKE_PLUGIN_NAME);
     CPPUNIT_ASSERT (library != NULL);
     CPPUNIT_ASSERT (_pm->instanciatePlugin (library, &plugin) == 0);
     CPPUNIT_ASSERT (plugin!=NULL);
@@ -80,32 +80,31 @@ void PluginManagerTest::testInitPlugin()
 {
     _debug ("-------------------- PluginManagerTest::testInitPlugin --------------------\n");
 
-    library = _pm->loadDynamicLibrary (PLUGIN_TEST_NAME);
+    library = _pm->loadDynamicLibrary (FAKE_PLUGIN_NAME);
     CPPUNIT_ASSERT (library != NULL);
     CPPUNIT_ASSERT (_pm->instanciatePlugin (library, &plugin) == 0);
     CPPUNIT_ASSERT (plugin!=NULL);
-    CPPUNIT_ASSERT (plugin->getPluginName() == PLUGIN_TEST_DESC);
+    CPPUNIT_ASSERT (plugin->getPluginName() == FAKE_PLUGIN_DESC);
 }
 
 void PluginManagerTest::testRegisterPlugin()
 {
     _debug ("-------------------- PluginManagerTest::testRegisterPlugin --------------------\n");
 
-    library = _pm->loadDynamicLibrary (PLUGIN_TEST_NAME);
+    library = _pm->loadDynamicLibrary (FAKE_PLUGIN_NAME);
     CPPUNIT_ASSERT (library != NULL);
     CPPUNIT_ASSERT (_pm->instanciatePlugin (library, &plugin) == 0);
-    CPPUNIT_ASSERT (_pm->isPluginLoaded (PLUGIN_TEST_DESC) == false);
+    CPPUNIT_ASSERT (_pm->isPluginLoaded (FAKE_PLUGIN_DESC) == false);
     CPPUNIT_ASSERT (_pm->registerPlugin (plugin, library) == 0);
-    CPPUNIT_ASSERT (_pm->isPluginLoaded (PLUGIN_TEST_DESC) == true);
+    CPPUNIT_ASSERT (_pm->isPluginLoaded (FAKE_PLUGIN_DESC) == true);
 }
 
 void PluginManagerTest::testLoadPlugins ()
 {
     _debug ("-------------------- PluginManagerTest::testLoadPlugins --------------------\n");
     try {
-    
-        CPPUNIT_ASSERT (_pm->loadPlugins (PLUGIN_TEST_DIR) == 0);
-        CPPUNIT_ASSERT (_pm->isPluginLoaded (PLUGIN_TEST_DESC) == true);
+        CPPUNIT_ASSERT (_pm->loadPlugins (FAKE_PLUGIN_DIR) == 0);
+        CPPUNIT_ASSERT (_pm->isPluginLoaded (FAKE_PLUGIN_DESC) == true);
     }
    catch (LibraryManagerException &e){
 	
@@ -118,10 +117,10 @@ void PluginManagerTest::testUnloadPlugins ()
 
     try {
 
-        CPPUNIT_ASSERT (_pm->loadPlugins (PLUGIN_TEST_DIR) == 0);
-        CPPUNIT_ASSERT (_pm->isPluginLoaded (PLUGIN_TEST_DESC) == true);
+        CPPUNIT_ASSERT (_pm->loadPlugins (FAKE_PLUGIN_DIR) == 0);
+        CPPUNIT_ASSERT (_pm->isPluginLoaded (FAKE_PLUGIN_DESC) == true);
         CPPUNIT_ASSERT (_pm->unloadPlugins () == 0);
-        CPPUNIT_ASSERT (_pm->isPluginLoaded (PLUGIN_TEST_DESC) == false);
+        CPPUNIT_ASSERT (_pm->isPluginLoaded (FAKE_PLUGIN_DESC) == false);
     }
     catch (LibraryManagerException &e) {
 
diff --git a/sflphone-common/test/pluginmanagertest.h b/sflphone-common/test/pluginmanagertest.h
index 35da2468f7a989857d2609c6240168cda4c1d171..2a2e78bf7815452763a334dad1bed040a2ec360d 100644
--- a/sflphone-common/test/pluginmanagertest.h
+++ b/sflphone-common/test/pluginmanagertest.h
@@ -94,6 +94,8 @@ class PluginManagerTest : public CppUnit::TestCase {
         void testUnloadPlugins ();
 
     private:
+        std::string FAKE_PLUGIN_DIR;
+        std::string FAKE_PLUGIN_NAME;
         PluginManager *_pm;
         LibraryManager *library;
         Plugin *plugin;