query_tree_emit: add test for 'clear', fix 'clear'