Make Groovy code sample more complete and more idiomatic