fixed bug with command hanging, added ensure_local function, added/restructured tests