Change "spec broken" details test so that other workflows can be tested too.
Add a new "Invalid workflow" with an error.

This is used later for testing the behaviour of this spec.
Change generator API: use write() for isolating generating from writing.

This allows better exception handling.
Do not write the definition.xml on error & improve error handling.

- The definition.xml should not be touched when there are any errors.
- When errors happen, we should write to the error_log but catch them and show
the user a portal message.