Adds test for TransactionCountThreshold and fixes some bugs in it