Add unit tests for publishing

Also includes pull request #124

Closes #124