Repeating events

Adds tests to #14 and fixes some non-obvious bugs.