Added a test for custom options.
Fixed bugs in generated code when there are no regular options.