Fix infinite loop in `isTestClass`

This fixes a case where an infinite loop can be encountered with HHVM when parsing code like this: https://github.com/zendframework/zf2/blob/fc64ed00440fe1948b8cb41d3b08c5f2b08c45bb/library/Zend/Mime/Exception/RuntimeException.php#L35

It appears that this may be due to a namespace detection issue, but ultimately putting a bound on the loop isn't a bad idea either.