TENET: Leveraging Tests Beyond Validation for Code Generation