Fix modulo operation in letter-shifting and add test