[1.5] Use new add_test signature to handle cross compilation and execution using wine
[1.5] Import first patch (fixes.patch) from issue 249 to fix leaks on error condition.

Update issue 249
[1.5] Declare functions static to track unused ones.