Pass connection context to transaction execution

My approach on/Targets #563.
You can still split the function _and_ have the code eduplicated:
The interface should not be changed, so I'd pull out the code into two functions (e.g. one for transactions, one for events). Those can _still_ get a pointer to the value as an parameter.