Added tests. Also, a small bugfix for how we allocate virtual streams. I...

...nstead of it in the event listener we do it outside of it.