Introduce a TransactionTemplate for automating transaction retries

This PR introduces a TransactionTemplate that can be used to automate transaction retries on exceptions. This template is then used in a flaky test that we know can cause exceptions upon which we want to simply retry the operation.
Formatting could be a tad better.