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.

(NOTE: This branch is work-in-progress. There are still a few things I need to clean up.)