Debug
Fix avg calculations and update unit tests