added testdir variable

testdir was not defined and the catch all exception did hide the error