Add specs and fix a bug.