fixed event total accounting and added tests