Refactor and cleanup

Test script in test.py now seems to be working smoothly. High-level
functions for subscribe/unsubscribe, publish/unpublish are done.

Clarified what's private and not.