manage_script_name fix for tricky resources

If the mountpoint is /foo or /foo/ then the following URIs should be managed:
* /foo
* /foo/
* /foo/anything

And, on the other side:
* /fooanything
* etc.
should be ignored.

Added some tests, too.
if mountpoint_len is 0 you corrupt memory here