Better detection for basepath while testing