Flappy test highlighted issue around infinite for loop and channel stops....

Flappy test highlighted issue around infinite for loop and channel stops. Added mutex lock to and additional stop check. Fixed.
Status Job ID Name Coverage
  Test
passed #9103045
test

00:00:36

 
  External
passed continuous-integration/codeship

00:02:01