rewrite the data_records index function

Now also with nodeunit tests for the some index functions.