Add and remove renderer inside the test to prevent leak.

This is similar to #15178.

\cc @senny