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.