Add tests for replacing files and dirs with symlinks and vice versa

This uncovered yet another variant of issue #36: Replacing a symlink
by a directory also does not work correctly.