refactor(subprocess): refactor for better mocking, DRY