events and states are now properties, code cleanup
added tests