cleanup context in most unit tests
Merge branch 'issue824' into 1.7.x
rebase