Fixed debug mode and testing detection