Write events and add tests