raise sooner when #write called on a failed transaction
refactor
doc