Added realtime unit tests

- Fixed minor bugs in the realtime code
- Fixed JSLint errors