There were async calls happening, so they weren't always finished when assert happened. I fixed it and made sure to add comments to the code and test with more explanation how and what.
I also fixed some compile warning I saw, see commit 9a6280cd