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