move findLeastElemContainingSpan() to utilities and test it