Fix opening TCK file in read/write mode. Added some tests.