Adds more testing for len(tree), and fixes a bug.