diff --git a/csc.scm b/csc.scm
index a39c3f5..885ea39 100644
--- a/csc.scm
+++ b/csc.scm
@@ -966,12 +966,13 @@ EOF
 	      TARGET_RUN_LIB_HOME)))
 
 (define (target-lib-path)
+  (or (get-environment-variable "TARGET_LIB_PATH")
       (let ((tdir TARGET_LIB_HOME))
 	(if (and (not (string=? tdir ""))
 		 cross-chicken
 		 (not host-mode))
 	    tdir
-	(lib-path))))
+	    (lib-path)))))
 
 (define (copy-libraries targetdir)
   (let ((lib (make-pathname
diff --git a/tests/runtests.sh b/tests/runtests.sh
index 7065564..b4a5f93 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -42,6 +42,11 @@ CHICKEN_INSTALL=${TEST_DIR}/../chicken-install
 CHICKEN_UNINSTALL=${TEST_DIR}/../chicken-uninstall
 ASMFLAGS=
 FAST_OPTIONS="-O5 -d0 -b -disable-interrupts"
+COMPILE_OPTIONS="-compiler ${TEST_DIR}/../chicken -v -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.."
+SETUP_PREFIX="-e (use setup-api)"
+SETUP_PREFIX="${SETUP_PREFIX} -e (register-program \"csc\" \"${TEST_DIR}/../csc\")"
+SETUP_PREFIX="${SETUP_PREFIX} -e (register-program \"chicken\" \"${TEST_DIR}/../chicken\")"
+SETUP_PREFIX="${SETUP_PREFIX} -e (register-program \"csi\" \"${TEST_DIR}/../csi\")"
 
 TYPESDB=../types.db
 cp $TYPESDB test-repository/types.db
@@ -61,9 +66,9 @@ if test -f ../cygchicken-0.dll; then
     mv ../cygchicken-0.dll ../cygchicken-0.dll_
 fi
 
-compile="../csc -compiler $CHICKEN -v -I.. -L.. -include-path .. -o a.out"
+compile="../csc -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS} -o a.out"
 compile2="../csc -compiler $CHICKEN -v -I.. -L.. -include-path .."
-compile_s="../csc -s -compiler $CHICKEN -v -I.. -L.. -include-path .."
+compile_s="../csc -s -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS} -v -I.. -L.. -include-path .."
 interpret="../csi -n -include-path .."
 
 rm -f *.exe *.so *.o *.import.* a.out ../foo.import.*
@@ -80,7 +85,7 @@ $compile inlining-tests.scm -optimize-level 3
 echo "======================================== scrutiny tests ..."
 $compile typematch-tests.scm -specialize -w
 ./a.out
-$compile scrutiny-tests.scm -A -scrutinize -ignore-repository -types $TYPESDB 2>scrutiny.out -verbose
+$compile scrutiny-tests.scm -A -scrutinize 2>scrutiny.out -verbose
 
 # this is sensitive to gensym-names, so make it optional
 if test \! -f scrutiny.expected; then
@@ -89,7 +94,7 @@ fi
 
 diff $DIFF_OPTS scrutiny.expected scrutiny.out
 
-$compile scrutiny-tests-2.scm -A -scrutinize -analyze-only -ignore-repository -types $TYPESDB 2>scrutiny-2.out -verbose
+$compile scrutiny-tests-2.scm -A -scrutinize -analyze-only 2>scrutiny-2.out -verbose
 
 # this is sensitive to gensym-names, so make it optional
 if test \! -f scrutiny-2.expected; then
@@ -98,10 +103,10 @@ fi
 
 diff $DIFF_OPTS scrutiny-2.expected scrutiny-2.out
 
-$compile scrutiny-tests-3.scm -specialize -block -ignore-repository -types $TYPESDB
+$compile scrutiny-tests-3.scm -specialize -block
 ./a.out
 
-$compile scrutiny-tests-strict.scm -strict-types -specialize -ignore-repository -types $TYPESDB
+$compile scrutiny-tests-strict.scm -strict-types -specialize
 ./a.out
 
 echo "======================================== specialization tests ..."
@@ -354,7 +359,7 @@ $interpret -bnq test-glob.scm
 echo "======================================== compiler/nursery stress test ..."
 for s in 100000 120000 200000 250000 300000 350000 400000 450000 500000; do
     echo "  $s"
-    ../chicken ../utils.scm -:s$s -output-file tmp.c -include-path .. 
+    ../chicken -ignore-repository ../utils.scm -:s$s -output-file tmp.c -include-path ..
 done
 
 echo "======================================== symbol-GC tests ..."
@@ -400,19 +405,24 @@ rm -fr rev-app rev-app-2 reverser/*.import.* reverser/*.so
 
 echo "======================================== reinstall tests"
 CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_UNINSTALL -force reverser
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_INSTALL -t local -l $TEST_DIR reverser:1.0 \
- -csi ${TEST_DIR}/../csi
+CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY CSC_OPTIONS=$COMPILE_OPTIONS \
+    CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL -t local -l $TEST_DIR \
+    -csi ${TEST_DIR}/../csi reverser:1.0
 CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $interpret -bnq rev-app.scm 1.0
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_INSTALL -t local -l $TEST_DIR -reinstall -force \
- -csi ${TEST_DIR}/../csi
+CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY CSC_OPTIONS=$COMPILE_OPTIONS \
+    CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL -t local -l $TEST_DIR \
+    -reinstall -force -csi ${TEST_DIR}/../csi
 CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $interpret -bnq rev-app.scm 1.0
 
 if test $OS_NAME != AIX -a $OS_NAME != SunOS -a $OS_NAME != GNU; then
 	echo "======================================== deployment tests"
 	mkdir rev-app
-	CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_INSTALL -t local -l $TEST_DIR reverser
-	CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $compile2 -deploy rev-app.scm
-	CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_INSTALL -deploy -prefix rev-app -t local -l $TEST_DIR reverser
+        TARGET_LIB_PATH=${TEST_DIR}/.. CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY CSC_OPTIONS=$COMPILE_OPTIONS \
+                          CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL -csi ${TEST_DIR}/../csi -t local -l $TEST_DIR reverser
+        TARGET_LIB_PATH=${TEST_DIR}/.. CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY CSC_OPTIONS=$COMPILE_OPTIONS \
+                          CSI_OPTIONS=$SETUP_PREFIX $compile2 -deploy rev-app.scm
+        TARGET_LIB_PATH=${TEST_DIR}/.. CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY CSC_OPTIONS=$COMPILE_OPTIONS \
+                          CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL -csi ${TEST_DIR}/../csi -deploy -prefix rev-app -t local -l $TEST_DIR reverser
 	unset LD_LIBRARY_PATH DYLD_LIBRARY_PATH CHICKEN_REPOSITORY
 	# An absolute path is required on NetBSD with $ORIGIN, hence `pwd`
 	`pwd`/rev-app/rev-app 1.1
