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.
Not sure why. I think it was already there i think when I first added the cleanup function or may be not. but perhaps if something does go wrong, having it in ```try..finally``` will at least cleanup the created images?