Fixed event handler/transition ordering, added tests.