Fix issue handling failed transactions, wrap openDatabase call