1723 another bugfix for tar

A new issue with the tar code was reported. I debugged and resolved the bug.

For review please note that i did three separate commits:
1. merging the upstream review results
2. create a testcase
3. fix the bug

Its easier to understand the change when you look at each commit at a time.