Fix issue #54 by making sure $HOME is only used when set

Original issue: https://bugzilla.wikimedia.org/show_bug.cgi?id=62240
Merge pull request #55 from hexmode/master

Fix issue #54 by making sure $HOME is only used when set