Cleaned the test programs a bit, used routines in testlib