Add test for jar_publish.  This required some refactoring so that functions could be mocked.

Includes a few minor cleanups to comments, error messages, docstrings,
etc.  This is in preparation for some improvements to how the scm integration is done.

Testing Done:
Ran the new tests and the integration tests.

Reviewed at https://rbcommons.com/s/twitter/r/1082/
Sync of https://github.com/pantsbuild/pants/commit/fb2f37f42e3dfce10512a4bf02018c32b508ebb7