fix tests for prior versions of python
tidy up exception handling in receiver loop