test msginit: share common chdir code