test_plot_implicit: Cleanup the figures created after the tests are over

I also refactored the existing code for the utility classes/functions
used in the tests into a separate module.
I'm not sure but is it really needed?