added testsuite for xterm256, corrected algorithm for grayscale