added clipping to proper range for color and pixel tolerance and a test for those