Optimal Debt Contracts and Moral Hazard Along the Business Cycle