lib/misc.js: added clamp_and_round_uint8(), clamp_and_round_int16() and build tests.