Add specs and fix problem uncovered by them.