properly cleanup Context for most of the unit tests
Merge branch 'issue824' into 1.7.x