small changes (local variables extracted to enhance readability,
given/when/then comments added to make the structure of examples clear)