fix some error handling
__enter__ return self

enables 'with X as Y' syntax