Improve the portability of code used in tests

This set of commits allows tests to pass on NetBSD-6.0 amd64. They still pass on Ubuntu-12.10 amd64. 

The biggest changes is to rework test build script to avoid bashim, as bash may not be available, or at least not available in /bin/bash. A possible other solution is to use /usr/bin/env bash as shell bang (untested but it will probably work).

Other part is the tweak on some Makefile rules. Commit log explains in more details why it is needed.

It would be nice to document too that one need rsync and a well-configured git to run the test.