Add specs for the generator
Fix a bug revealed by the new specs :)