Splits as close to the end as possible.

def split_msg(msgs: List[bytes], max_len: int) -> Tuple[str, List[bytes]]:
    """Splits as close to the end as possible."""
    msg = ""
    while len(msg.encode()) < max_len:
        if len(msg.encode()) + len(msgs[0]) > max_len:
            return msg, msgs
        char = msgs.pop(0).decode()
        # If we have a space within 15 chars of the length limit, split there to avoid words being broken up.
        if char == " " and len(msg.encode()) > max_len - 15:
            return msg, msgs
        msg += char
    return msg, msgs