Fixing transaction leakage in REST api

This fixes #1778