diff --git a/Tests/Functional/Python/PyCore/CMakeLists.txt b/Tests/Functional/Python/PyCore/CMakeLists.txt
index 9d195c49ec556d2b9f26b5c25a5f7fb7dd0c69a6..bd77f6d3fd158cfbe56f3978155bd8ac6dd05404 100644
--- a/Tests/Functional/Python/PyCore/CMakeLists.txt
+++ b/Tests/Functional/Python/PyCore/CMakeLists.txt
@@ -5,18 +5,17 @@
 set(OUTPUT_DIR ${TEST_OUTPUT_DIR_PY_CORE})
 file(MAKE_DIRECTORY ${OUTPUT_DIR})
 
-file(GLOB sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.py")
+file(GLOB tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.py")
+list(REMOVE_ITEM tests utils.py)
 if(NOT BORNAGAIN_TIFF_SUPPORT)
-    list(REMOVE_ITEM sources "intensitydata_io_tiff.py")
+    list(REMOVE_ITEM tests "intensitydata_io_tiff.py")
 endif()
 
-foreach(_src ${sources})
-    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${_src} ${OUTPUT_DIR}/${_src} @ONLY)
-endforeach()
-
-set(tests ${sources})
-list(REMOVE_ITEM tests utils.py)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/utils.py ${OUTPUT_DIR}/utils.py)
 
 foreach(_test ${tests})
-    add_test(PyCore.${_test} ${Python3_EXECUTABLE} ${OUTPUT_DIR}/${_test})
+    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${_test} ${OUTPUT_DIR}/${_test} COPYONLY)
+    add_test(PyCore.${_test}
+        env PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
+        ${Python3_EXECUTABLE} ${OUTPUT_DIR}/${_test})
 endforeach()
diff --git a/Tests/Functional/Python/PyCore/histogram2d.py b/Tests/Functional/Python/PyCore/histogram2d.py
index 84c639fe60acd65fa1b97763f04045b5aac12b9d..c9df823fc106c1d7ae2f36d2d6c95e1131af61fb 100644
--- a/Tests/Functional/Python/PyCore/histogram2d.py
+++ b/Tests/Functional/Python/PyCore/histogram2d.py
@@ -1,6 +1,4 @@
 import numpy, os, sys, unittest
-
-sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
 import bornagain as ba
 
 
diff --git a/Tests/Functional/Python/PyCore/intensitydata.py b/Tests/Functional/Python/PyCore/intensitydata.py
index bb6befd4d55f1ca540f9947c51480f6d899e7a58..e32620b5761b4456c2321d1fef2327618f7427ef 100644
--- a/Tests/Functional/Python/PyCore/intensitydata.py
+++ b/Tests/Functional/Python/PyCore/intensitydata.py
@@ -1,8 +1,6 @@
 # Functional test: tests of IntensityData object
 
 import numpy, os, sys, unittest
-
-sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
 import bornagain as ba
 
 
diff --git a/Tests/Functional/Python/PyCore/intensitydata_io.py b/Tests/Functional/Python/PyCore/intensitydata_io.py
index f45b73ce23ba2440a47d18f09631a78a36d858c4..d11811068d2c1daa1e9d61dcc9abfda6fb6dba38 100644
--- a/Tests/Functional/Python/PyCore/intensitydata_io.py
+++ b/Tests/Functional/Python/PyCore/intensitydata_io.py
@@ -1,8 +1,6 @@
 # Functional test: tests of IO operations with the IntensityData object
 
 import math, numpy, os, sys, time, unittest
-
-sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
 import bornagain as ba
 from bornagain import deg, deg2rad, rad2deg
 
diff --git a/Tests/Functional/Python/PyCore/intensitydata_io_tiff.py b/Tests/Functional/Python/PyCore/intensitydata_io_tiff.py
index 8ae1ad26bb573b3d8aa2cc250fc558bde0d78fa8..4b6e0f29ea8276f31dca5e720182f4d7b66aad09 100644
--- a/Tests/Functional/Python/PyCore/intensitydata_io_tiff.py
+++ b/Tests/Functional/Python/PyCore/intensitydata_io_tiff.py
@@ -1,8 +1,6 @@
 # Functional test: tests of IO operations with the IntensityData object
 
 import math, numpy, os, sys, time, unittest
-
-sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
 import bornagain as ba
 
 
diff --git a/Tests/Functional/Python/PyCore/parameterpool.py b/Tests/Functional/Python/PyCore/parameterpool.py
index ca8d9d0252d1e16996bf01be127de90483996458..d61107d8fa06697b54d28a9354fbd02cf84b40db 100644
--- a/Tests/Functional/Python/PyCore/parameterpool.py
+++ b/Tests/Functional/Python/PyCore/parameterpool.py
@@ -1,6 +1,4 @@
 import numpy, os, sys, unittest
-
-sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
 import bornagain as ba
 from bornagain import nm
 
diff --git a/Tests/Functional/Python/PyCore/samplebuilder.py b/Tests/Functional/Python/PyCore/samplebuilder.py
index 35dd5ab702679a4a61ab97a7fb1deafd29efbe3d..a8628a3f00297a5e1b1a6eb86271849546ba1c85 100644
--- a/Tests/Functional/Python/PyCore/samplebuilder.py
+++ b/Tests/Functional/Python/PyCore/samplebuilder.py
@@ -1,7 +1,5 @@
 import sys, unittest, ctypes
 import inspect
-
-sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
 import bornagain as ba
 
 initial_width = 42
diff --git a/Tests/Functional/Python/PyCore/shape2d.py b/Tests/Functional/Python/PyCore/shape2d.py
index ad92c8211c84231b1c32cead1c399fa953c1e4cf..794763c866023c585212b9d63a17d86795ad9937 100644
--- a/Tests/Functional/Python/PyCore/shape2d.py
+++ b/Tests/Functional/Python/PyCore/shape2d.py
@@ -1,6 +1,4 @@
 import numpy, os, sys, unittest
-
-sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
 import bornagain as ba
 
 
diff --git a/Tests/Functional/Python/PyCore/utils.py b/Tests/Functional/Python/PyCore/utils.py
index e17bba8b0543e96a73f88200e09b3111cdee0d36..ab4ff98bd51404693bee29f870da72e4fd25e783 100644
--- a/Tests/Functional/Python/PyCore/utils.py
+++ b/Tests/Functional/Python/PyCore/utils.py
@@ -3,8 +3,6 @@ Collection of utils for testing
 """
 
 import gzip, numpy, sys, os
-
-sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
 import bornagain as ba
 from bornagain import deg, angstrom
 
@@ -42,39 +40,7 @@ def get_reference_data(filename):
         os.path.join(REFERENCE_DIR, filename))
 
 
-def get_simulation_MiniGISAS(sample=None):
-    simulation = ba.GISASSimulation()
-    simulation.setDetectorParameters(25, -2.0*deg, 2.0*deg, 25, 0.0*deg,
-                                     2.0*deg)
-    simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg)
-    if sample:
-        simulation.setSample(sample)
-    return simulation
-
-
-def get_simulation_BasicGISAS(sample=None):
-    simulation = ba.GISASSimulation()
-    simulation.setDetectorParameters(100, 0.0*deg, 2.0*deg, 100, 0.0*deg,
-                                     2.0*deg)
-    simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg)
-    if sample:
-        simulation.setSample(sample)
-    return simulation
-
-
-def plot_int(intensity):
-    import matplotlib, pylab
-    data = intensity.getArray() + 1
-    # data = numpy.abs(intensity.getArray())
-    phi_min = rad2deg(intensity.axis(0).lowerBound())
-    phi_max = rad2deg(intensity.axis(0).upperBound())
-    alpha_min = rad2deg(intensity.axis(1).lowerBound())
-    alpha_max = rad2deg(intensity.axis(1).upperBound())
-    im = pylab.imshow(data,
-                      norm=matplotlib.colors.LogNorm(),
-                      extent=[phi_min, phi_max, alpha_min, alpha_max])
-    cb = pylab.colorbar(im)
-    cb.set_label(r'Intensity (arb. u.)', size=16)
-    pylab.xlabel(r'$\phi_f (^{\circ})$', fontsize=16)
-    pylab.ylabel(r'$\alpha_f (^{\circ})$', fontsize=16)
-    pylab.show()
+def get_simulation_MiniGISAS(sample):
+    detector = ba.SphericalDetector(25, -2*deg, 2*deg, 25, 0*deg, 2*deg)
+    beam = ba.Beam(1., 1*angstrom, ba.Direction(0.2*deg, 0))
+    return ba.GISASSimulation(beam, sample, detector)