Refactor and test deploy

This adds a lot of missing test coverage for the `zpm deploy` code path.

The most significant change is the addition of the `Deploy` class, which encapsulates most of the functionality.