Commit open transactions when attaching

Fix for issue #51