Refactor using PublishResult
Fix tests