tests: fix build of tests when the build directory is outside source tree (closes #178)

(cherry picked from commit f39b37351c509c180475dbdfbe01001ebfac13a4)