fixes qi encoding ns, checks constructed trees in test