Count number of calls to onRecordFn correctly in all cases