Fix transaction middleware for using=None