Learning Optimal Contracts: How to Exploit Small Action Spaces