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.
The predicate should be used in the retry-loop to determine if the thrown exception is one to retry on, it is currently unused.