Added example and tests for histogram and fixed bad code