Rewrite and test pub_sub