Unit tests + bug fixes for binning.py