.[anything] will select either this node (if the predicate is true) or
nothing otherwise, so the count is always 0 or 1.
I'd guess you intended count(../tocItem[lesson/lessontitle='Lesson A'])
although it might be ore efficient to work out that number into a
variable before starting the loop or perhaps your xslt system will be
smart enough to notice that the value doesn't depend on the current item
if that was selected with the child axis.