Use MAX_LENGTH constant for random length max

`MAX_LENGTH` wasn't being used. This swaps out the hardcoded max length value of `1024` for the constant.