On Certifying and Improving Generalization to Unseen Domains