tests: Build test code on FreeBSD the same way as on Linux