[fix] end stream on destroy or error
[fix] max counter query
[test] complete testsuite for currently implemented features