Added test case that checks that the correct state changes are made and no extra events are triggered. Also cleaned up the log checking function.