Fix regression for django.db.transaction.managed()

Hi,
My last changes brought a regression in transaction.managed(), that I want to fix.
I added a test to make sure it won't happen again.

Thanks

Nicolas