Fixed event bugs and tests