fixing issue #171

Fixes situation when HOME=/root and /any/other/dir/root
will be replaced with /any/other/dir~