diff --git a/Device/Data/DataUtils.cpp b/Device/Data/DataUtils.cpp
index 7002d4001ff26257f6074bc8c45bfc2c7a70821e..d22cc4d67df5a1cb9d6a80dc3bedfacb093a867a 100644
--- a/Device/Data/DataUtils.cpp
+++ b/Device/Data/DataUtils.cpp
@@ -43,7 +43,7 @@ double DataUtils::Data::relativeDataDifference(const OutputData<double>& dat,
         diff += Numeric::GetRelativeDifference(dat[i], ref[i]);
     diff /= dat.getAllocatedSize();
     if (std::isnan(diff))
-        throw std::runtime_error("diff=NaN!");
+        throw std::runtime_error("diff=NaN");
     return diff;
 }
 
diff --git a/Device/Histo/HistoUtils.cpp b/Device/Histo/HistoUtils.cpp
index a44512186a19f6e0865160f338cec62731ab448d..e8e2bdec40d893faa319951e4cd1470006420910 100644
--- a/Device/Histo/HistoUtils.cpp
+++ b/Device/Histo/HistoUtils.cpp
@@ -90,18 +90,22 @@ bool DataUtils::Histo::checkRelativeDifference(const OutputData<double>& dat,
         return false;
     }
 
-    const double diff = DataUtils::Data::relativeDataDifference(dat, ref);
-    if (diff > threshold) {
-        std::cerr << "FAILED: relative deviation of dat from ref is " << diff
-                  << ", above given threshold " << threshold << std::endl;
+    try {
+        const double diff = DataUtils::Data::relativeDataDifference(dat, ref);
+        if (diff > threshold) {
+            std::cerr << "FAILED: relative deviation of dat from ref is " << diff
+                      << ", above given threshold " << threshold << std::endl;
+            return false;
+        }
+        if (diff)
+            std::cerr << "- OK: relative deviation of dat from ref is " << diff
+                      << ", within given threshold " << threshold << std::endl;
+        else
+            std::cout << "- OK: dat = ref\n";
+        return true;
+    } catch (...) {
         return false;
     }
-    if (diff)
-        std::cerr << "- OK: relative deviation of dat from ref is " << diff
-                  << ", within given threshold " << threshold << std::endl;
-    else
-        std::cout << "- OK: dat = ref\n";
-    return true;
 }
 
 bool DataUtils::Histo::agreesWithReference(const SimulationResult& dat,
diff --git a/Examples/ff/Pyramid4.py b/Examples/ff/Pyramid4.py
index 3e583f53c389616e1904040d8cba790fbb8bb2df..aecc04eff25b18f729b379003a8e4aecea962e58 100755
--- a/Examples/ff/Pyramid4.py
+++ b/Examples/ff/Pyramid4.py
@@ -3,4 +3,5 @@ import bornagain as ba
 from bornagain import deg, nm, ff_demo
 
 ff = ba.FormFactorPyramid4(10*nm, 5*nm, 54.73*deg)
-ff_demo.run_and_plot_sas_ff(ff)
+if __name__ == '__main__':
+    ff_demo.run_and_plot_sas_ff(ff)
diff --git a/Tests/Examples/CMakeLists.txt b/Tests/Examples/CMakeLists.txt
index 669c3e40ba90622636c3edeb40242458cd246a4c..acaa9169db0070ce25b3bc59e058feb65aa4271c 100644
--- a/Tests/Examples/CMakeLists.txt
+++ b/Tests/Examples/CMakeLists.txt
@@ -64,6 +64,8 @@ endfunction()
 #  Persistence tests
 ####################################################################################################
 
+test_example(ff/Pyramid4 2e-10)
+
 test_example(scatter2d/ApproximationDA 2e-10)
 test_example(scatter2d/ApproximationLMA 2e-10)
 test_example(scatter2d/ApproximationSSCA 2e-10)
diff --git a/Tests/Examples/PyPersistence.py.in b/Tests/Examples/PyPersistence.py.in
index a0834b27ff58ba5589d83998b9a34d5af6c66c80..85d2b1b7b18290ceac7ab8f88de17a2564b69160 100644
--- a/Tests/Examples/PyPersistence.py.in
+++ b/Tests/Examples/PyPersistence.py.in
@@ -24,14 +24,6 @@ example = __import__(EXAMPLE_NAME)
 simulationObject = None
 
 
-def get_simulation_SpecularSimulation():
-    """
-    Returns custom simulation for SpecularSimulation.py.
-    """
-    simulation = example.get_simulation(example.get_sample(), scan_size=10)
-    return simulation
-
-
 def get_simulation_DepthProbe():
     """
     Returns custom simulation in the case of depth probe.
@@ -82,7 +74,10 @@ def get_minified_simulation():
     Returns a simulation constructed from example simulation with smaller detector.
     """
     if "specular" in EXAMPLE_DIR:
-        return get_simulation_SpecularSimulation()
+        return example.get_simulation(example.get_sample(), scan_size=10)
+
+    if "ff" in EXAMPLE_DIR:
+        return ba.ff_demo.get_simulation(ba.ff_demo.get_sample(example.ff), 10)
 
     elif EXAMPLE_NAME == "RectangularGrating":
         return get_simulation_RectangularGrating()
diff --git a/Tests/ReferenceData/ExamplesMini/Pyramid4.int.gz b/Tests/ReferenceData/ExamplesMini/Pyramid4.int.gz
new file mode 100644
index 0000000000000000000000000000000000000000..09da9c1decf9ecb323ed313f25c6df8e47f598ce
Binary files /dev/null and b/Tests/ReferenceData/ExamplesMini/Pyramid4.int.gz differ
diff --git a/Wrap/Python/ff_demo.py b/Wrap/Python/ff_demo.py
index 17dba359239f5970e0c3c6d81561e5e6520a55e9..ba7d2831cbc6999a45851e6199e5c81977550c28 100644
--- a/Wrap/Python/ff_demo.py
+++ b/Wrap/Python/ff_demo.py
@@ -30,15 +30,14 @@ def get_sample(ff):
     return sample
 
 
-def get_simulation(sample):
+def get_simulation(sample, nPix):
     # Beam from above (perpendicular to sample):
     beam = ba.Beam(1, 0.4*nm, ba.Direction(90*deg, 0))
 
     # Detector opposite to source:
     detPos = 2000  # distance from sample center to detector in mm
     detWid = 500  # detector width in mm
-    detPix = 200  # number of pixels per direction
-    det = ba.RectangularDetector(detPix, detWid, detPix, detWid)
+    det = ba.RectangularDetector(nPix, detWid, nPix, detWid)
     det.setPerpendicularToDirectBeam(detPos, detWid/2, detWid/2)
 
     return ba.ScatteringSimulation(beam, sample, det)
@@ -46,5 +45,5 @@ def get_simulation(sample):
 
 def run_and_plot_sas_ff(ff):
     sample = get_sample(ff)
-    simulation = get_simulation(sample)
+    simulation = get_simulation(sample, 200)
     ba_plot.run_and_plot(simulation)