add tests and fix bugs for LineFileInMemory