refactored db transaction handling code

to prevent transaction nesting (see RM ticket 3438).
this also includes a bugfix for the wrong method call for starting manually managed transactions (see RM ticket 3430).