Add a test for 'dump'
Refactor 'dump' to work on all supported python versions