-/pkgTest/src/d.o
+/pkgTest/src/sources/d.o
+/pkgTest/src/tests/t.d.o
 /pkgTest/src/pkgTest.so
 
 
     if (file.exists(file.path(path,"src"))) {
         # C code -- Warning: src/tests folder should not be listed
-        cFiles = list.files( file.path(path,"src"), pattern="\\.[cChH]$",
-            full.names=TRUE, recursive=TRUE, no..=TRUE )
-        cFiles = lapply(cFiles, function(x) {
-            if (nchar(x)>=5 && substr(x,1,5)=="tests") return ("")
-            return (x)
-        })
-        
+        cFiles = c(
+        list.files(file.path(path,"src","sources"),pattern="\\.[cChH]$",
+            full.names=TRUE, recursive=TRUE, no..=TRUE),
+        list.files(file.path(path,"src","adapters"),pattern="\\.[cChH]$",
+            full.names=TRUE, recursive=TRUE, no..=TRUE))
+
         # Create folder R_HOME_USER/pkgdev/pkgs/pkgName/src (if not existing)
         dir.create(file.path(pkdev_path,"pkgs",pkgName,"src"), showWarnings=FALSE)
         
 
 
     # Initial step: list every potential unit test under path/R/tests.
     allFuncNames = .parseRunitTests(file.path(path,"R","tests"))
-    
+
     # Filter functions names matching prefix
-    funcNames = grep( paste("^test\\.",prefix,sep=''), allFuncNames, value=TRUE )
+    funcNames = grep( paste("^test_",prefix,sep=''), allFuncNames, value=TRUE )
     if (length(funcNames) == 0) return #shortcut: nothing to do...
     
     # If show==TRUE, display every potential test starting with prefix, and exit
         # If the file is not a source, skip
         if ( length( grep("\\.[RrSsq]$", fileName) ) == 0) next
         
-        # Every test function has a name starting with "test."
+        # Every test function has a name starting with "test_"
         matches = grep(
-            "^[ \t]*test\\.[a-zA-Z0-9_]*[ \t]*(=|<-)[ \t]*function.*",
+            "^[ \t]*test_[a-zA-Z0-9_]*[ \t]*(=|<-)[ \t]*function.*",
             scan(fileName, what="character", sep='\n', quiet=TRUE),
             value = TRUE)
         
         # We matched more to be 100% sure we got test functions, but need to strip now
         funcNames = c(funcNames, sub(
-            "^[ \t]*(test\\.[a-zA-Z0-9_]*)[ \t]*(=|<-)[ \t]*function.*",
+            "^[ \t]*(test_[a-zA-Z0-9_]*)[ \t]*(=|<-)[ \t]*function.*",
             "\\1",
             matches))
     }
 
--- /dev/null
+#called by library(pkgdev)
+.onAttach = function(libname, pkgname) {
+       #wipe all previous "loaded" tags
+       R_HOME_USER = Sys.getenv("R_HOME_USER")
+       if (R_HOME_USER != "") {
+               pkgdevPackagesPath = file.path( Sys.getenv("R_HOME_USER"),"pkgdev","pkgs" )
+               for (package in list.dirs(pkgdevPackagesPath, recursive=FALSE))
+                       file.remove(file.path(package,"loaded"))
+       }
+}
 
 # Export all user-level R functions
-export (a, b, c, .Last.lib)
+export (a, b, c)
 
 useDynLib(pkgTest)
 
--- /dev/null
+test_a = function() {
+       a()
+}
+
+test_c = function() {
+       c()
+}
 
 #called when package is detached ( detach("package:pkg_name") )
-.Last.lib = function(path)
+.onDetach = function(libpath)
 {
-       library.dynam.unload("pkgTest", path)
+       library.dynam.unload("pkgTest", libpath)
 }
 
--- /dev/null
+void test_d() {
+       d();
+}