Improved event batching, added test