Refactored UpdateService.

Cleaned up the code and applied some dependency injection to make
testing easier.