Fixed bug in _mean_std function, added exceptions and minor cleanups.
Updated tests for threshold_niblack and threshold_sauvola.