Fix handling of latest metric when there is no data. Also tests.