Updated the toDataURL test to completly fix #186

This adds another test (todataurl) to check if any of the formats are
supported, it also DRYs up the code a bit by abstracting the nearly
identical tests into a function.