improved the final comparison in test_all() to be much more robust and elegant