[TEST] wait for no pending tasks so processed all mappings
[TEST] also assert that put mapping is ack'ed
[QUERY] Remove Queries#optimizeQuery(...)

This method tires to optimize boolean queries if there is only
one clause. Yet BooleanQuery already does that internally This
optimization is unneeded.

Closes #6743