Add hanging condition test

And fix possible error in re-search-forward
added if-switch-cond