Fix inconsistent caching behaviour in Dataset.map() with multiprocessing #3044
Fix #3044

1. A rough unit test that fails without the fix. It probably doesn't comply with your code standards, but that just to draft the idea.
2. A one liner fix 