add tree test for envelope, fix bug