change return value of data_output, add data_free
change return of output
add more test for functions