Make FD passing in file_open_as more robust

Send an FD in all cases instead of relying on a close call to abort a
pending recvmsg in a reliable way.

Chnage sendfd/passfd to allow sending -1 as FD.
tests: Refactor common code and adapt to changed allocate_string function

Also add simple compile script.