rewrite TypeTest to make more readable