Fixed ff881aef on Python 3.
Fixed #20234 and #20236 -- SingleObjectMixin fixes

Added object on SingleObjectMixin returned context,
some code clanup.