diff --git a/bob/ip/binseg/data/stare/__init__.py b/bob/ip/binseg/data/stare/__init__.py
index c673d62e5330c27ad76e4c8e13ad29d3611015d2..faeac3896ad6a1b9982bd39d7b7d37a27c9dac16 100644
--- a/bob/ip/binseg/data/stare/__init__.py
+++ b/bob/ip/binseg/data/stare/__init__.py
@@ -43,7 +43,8 @@ _root_path = bob.extension.rc.get(
     "bob.ip.binseg.stare.datadir", os.path.realpath(os.curdir)
 )
 
-def _make_dataset(root_path):
+
+def _make_loader(root_path):
 
     def _loader(context, sample):
         # "context" is ignore in this case - database is homogeneous
@@ -52,10 +53,15 @@ def _make_dataset(root_path):
             label=load_pil_1(os.path.join(root_path, sample["label"])),
         )
 
+    return _loader
+
+
+def _make_dataset(root_path):
+
     return JSONDataset(
         protocols=_protocols,
         fieldnames=_fieldnames,
-        loader=_loader,
+        loader=_make_loader(root_path),
         keymaker=data_path_keymaker,
     )
 
diff --git a/bob/ip/binseg/test/test_csv.py b/bob/ip/binseg/test/test_csv.py
index 107d9c19ef9b7e979dc20cd5bddf535795c0f924..482a0fc81a0d2dd10bab85183b51ce744b812ba9 100644
--- a/bob/ip/binseg/test/test_csv.py
+++ b/bob/ip/binseg/test/test_csv.py
@@ -13,7 +13,7 @@ from ..data import stare
 ## special trick for CI builds
 from . import mock_dataset, TESTDB_TMPDIR
 
-json_dataset, rc_variable_set = mock_dataset()
+datadir, json_dataset, rc_variable_set = mock_dataset()
 
 
 ## definition of stare subsets for "default" protocol
@@ -50,17 +50,10 @@ stare-images/im0324.ppm,labels-ah/im0324.ah.ppm"""
 @rc_variable_set("bob.ip.binseg.stare.datadir")
 def test_compare_to_json():
 
-    if TESTDB_TMPDIR is not None:
-        stare_dir = TESTDB_TMPDIR.name
-    else:
-        import bob.extension
-
-        stare_dir = bob.extension.rc.get("bob.ip.binseg.stare.datadir")
-
     test_dataset = CSVDataset(
         default,
         stare._fieldnames,
-        stare._make_loader(stare_dir),
+        stare._make_loader(datadir),
         stare.data_path_keymaker,
     )