Emitted stream end events when the stream closes
Added missing tests for queries