Write a fully functioning Python service from scratch, including comprehensive unit tests, to process a stream of incoming event records for Vendelux. Implement the required behavior as a pure function that validates records, rejects malformed or duplicate events, and aggregates accepted events by type. Input is a list of dictionaries with event_id, event_type, timestamp, and payload; return accepted IDs, indexed rejection reasons, counts by type, and the latest timestamp by type.
def process_event_stream(events):