Add userdir testcases. This also fixes an undefined value.