Test and refactor TreeInfo#defTree

Review by @odersky