Fix publish_P and add test coverage