Context manager generator for retry block pattern and decorator.

I have also added some more tests here. However, it is not possible to read the isolation level for the current transaction so cannot verify that directly.