fix dataset.map for function without outputs
As noticed in #505 , giving a function that doesn't return anything in `.map` raises an error because of an unreferenced variable.
I fixed that and added tests.

Thanks @avloss for reporting