Fix PR1355: Only compute the SUBPATH and TESTDIR once.