Fixed a minor bug, reorganized and added more tests.
Merge branch 'events-refactor' into dev-ev-refactor