rebased patch.
Only changes to the tests due to the revert of nested querytracking in f85f6ab051b
Regards,
Sami