add value range check for C level assignments to bytearray indices in order to mimic the safe Python behaviour
clean up some code redundancy