@polesye. You are right. It's fixed, I count instead the numbers of calls that have been made to focus after the two loops have iterated. It has to be equal to 2 * (nbr of speed entries):

expect($.fn.focus.calls.length).toEqual(2*speedEntries.length);