Additional fixes for log table including test queries.

Refs #4433
Livestatus: Fix filter stack counter problem (and, or) causing empty query results.

Fixes #5016
Livestatus: Fix crash when socket exception is thrown during query reponse.

Fixes #4619