Implemented data_end parameter and wrote more tests