added tests and fixed events