diff --git a/SAS/LSMR/bin/lsmr_testdatabase b/SAS/LSMR/bin/lsmr_testdatabase
old mode 100644
new mode 100755
index e0b393192e32cba252c0bfa637e15accc80d0550..d902d10e4e3a94915e764fbd03ad033fc19b057d
--- a/SAS/LSMR/bin/lsmr_testdatabase
+++ b/SAS/LSMR/bin/lsmr_testdatabase
@@ -18,13 +18,28 @@
 # with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
 
 
-# Script to run a temporary postgres instance for easy functional testing
+# Script to create, setup, and run a temporary postgres instance for easy functional testing
 
-echo "---"
-echo "! This is for testing only! Database is not persistent!"
-echo "---"
+#defaults
+CREDENTIALS="lsmr_test"
 
+# Parse args:
+while getopts "C:h" opt; do
+  case ${opt} in
+    C ) CREDENTIALS=${OPTARG} ;;
+    h ) echo "usage: lsmr_testdatabase [OPTIONS]"
+        echo "  where options are:"
+        echo "    -C <credentials-name> the name of the credentials in ~/.lofar/dbcredentials. default=$CREDENTIALS"
+        exit 0
+        ;;
+  esac
+done
 
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+echo "!!! This is for testing only! Database is not persistent !!!"
+echo "Using credentials=$CREDENTIALS"
+
+# the lsmr django settings module reads this environment variable when available to determine the used database.
+export LSMR_DBCREDENTIALS=$CREDENTIALS
 
-/usr/bin/env python3 ${LOFARROOT}/../SAS/LSMR/test/postgres_testrunner.py
\ No newline at end of file
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+/usr/bin/env python3 $DIR/../lib*/python*/site-packages/lofar/sas/lsmr/test/postgres_testrunner.py
diff --git a/SAS/LSMR/test/CMakeLists.txt b/SAS/LSMR/test/CMakeLists.txt
index c9c9dc81f7b75783d6f7ad42f34d59cee1c52c90..42d75396943652ddefdc3838475ec4932fc8c9e7 100644
--- a/SAS/LSMR/test/CMakeLists.txt
+++ b/SAS/LSMR/test/CMakeLists.txt
@@ -20,4 +20,6 @@ set(_py_files
     __init__.py
     postgres_testrunner.py
 )
-file(COPY ${_py_files} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
\ No newline at end of file
+python_install(${_py_files}
+    DESTINATION lofar/sas/lsmr/test)
+
diff --git a/SAS/LSMR/test/postgres_testrunner.py b/SAS/LSMR/test/postgres_testrunner.py
index 2e6ec0945b3c8845f4aa590ebf15b5364fed68d5..1309cd0614ee02b0584c8135b0a135bfd83c8f6d 100755
--- a/SAS/LSMR/test/postgres_testrunner.py
+++ b/SAS/LSMR/test/postgres_testrunner.py
@@ -105,14 +105,21 @@ class PostgresqlTestRunner(DiscoverRunner):
 
 if __name__ == "__main__":
     """
-    Start Django test database and keep it alive until interrupted
+    Start Django test database and keep it alive until interrupted.
+    It will use the database credentials found in ~/.lofar/dbcredentials 
+    for the name found in environment variable LSMR_DBCREDENTIALS, or 'lsmr' if the env var is not set.
+    See also settings.py and the lsmr_testdatabase script for usage. 
     """
 
     pg = create_test_Postgres_from_django_settings()
-    name = DATABASES['default']['NAME']
-    create_project_db(pg, name)
-
-    print("Started Postgres server according to settings.py details with PID %s" % pg.server_pid)
+    create_project_db(pg, DATABASES['default']['NAME'])
+
+    print("Started Postgres server for lsmr django: dbname=%s user=%s host=%s port=%s PID=%s" % (
+        DATABASES['default']['NAME'],
+        DATABASES['default']['USER'],
+        DATABASES['default']['HOST'],
+        DATABASES['default']['PORT'],
+        pg.server_pid))
     print("Waiting for your interrupt to stop it.")
     while True:
         time.sleep(1)