refactor metrics and fix review coments
add metric in test and refactor tests