Fixes in TreeRepository

insertSelect will not work in unit tests, since they're in a temp table

Change-Id: I2af85eaad24bf45926dbe2505afdfca82ab28854
Merge "Fixes in TreeRepository"