Fixed exception durong event dispatching on surface.
Added functional tests.
Added functional tests.