Fix file open and save function.
Add test code.