Implement statejoin & fix related bugs

This adds statejoin & a test case

Note that a lot of code was cleanup up / fixed.

Outstanding items that we should fix in the future:

- Subtle race condition in sendUpdate with regards to dictionary mutation
- Subtle timing desynchronisation related to using time.After and time.Tick