fix test linking with --as-needed