hwrt/data_analyzation_metrics.py: Made code more robust; added unit tests