fix open() problem and add test case