Refactor broker into publisher and subscriber

This is not a unit test. Move it to another file?