Fix TwoWaySearcher to work when used with periodic needles.

There is a check in TwoWaySearcher::new to determine whether the needle is periodic. This is needed because during searching when a match fails, we cannot advance the position by the entire length of the needle when it is periodic, but can only advance by the length of the period.

The reason "bananas".contains("nana") (and similar searches) were returning false was because the periodicity check was wrong.

Closes #16589

Also, thanks to @Gankro, who came up with many buggy examples.
Actually, I'm worried about that. `maximal_suffix` is giving different periods for those two, which seems to contradict how my port of glibc's `critical_factorization` function works.