Fix LDFLAGS=-Wl,--as-needed incompatibility introduced in ee15a2a9.

...d in ee15a2a9.

Uses LIBS instead of LDFLAGS for -l flags in the tests as appropriate
to ensure proper linker flag ordering in the test comparing -R and
-rpath.

See downstream [gentoo bug #461748](https://bugs.gentoo.org/461748).

P.S., it would be nice to get this fix out as a new release too ;-). Maybe wait a few days to see if anything else important shows up and throw on a new tag or do that now? That would be awesome!