tests: Fix plugin unload

Plugin unload must happen before ending the test.