fix completion notification for greenlets

The 'command' variable was bound to its last value in the loop, so we
were marking the wrong command as completed in case more than one
arrived at once. As a result, some commands would be executed twice.

This patch also adds a reproducer to the test suite, and some extra
sanity checking for command status changes (similar to the sanity
checking for task status added in 0.12.0).

Bug: 951309
Change-Id: Ic89c7fe6131e936128f2cb197c6c182e57c0fae1
Merge "fix completion notification for greenlets" into release-0.12