Fixed bug using wrong variable in max event compare
Added unit test for max event counts