Unify and cleanup rpath handling in tests.