REFACTOR transactionAnalytics with test case added