NginxTest: unbreak unit tests under MacOS with BSD's sed.

Replaces usage of sed by similar perl command.

I also revert a small part of changes from 7321217596f69c2e4b312862a9407bea4f96c8c4
commit where egor@ disabled these tests under MacOS.

Resolve #447 (and also fix #439 properly).