Added unit tests and corrected minor bug in heatmap.