pubsub fixes and corresponding unit tests