Fix input_reader memory usage by using cursors
Add input_reader test case