Clean up and export HOME if not set

Change-Id: Icf300cec4f7d1c52be7e4c90119463f240874eb2