[MGN-57] Fix code for getting latest datapoint in a timeseries
[MGN-57] Unit test for getting the latest datapoint in a timeseries