DataDirectory actually has variable size - as in: not all entries have to be present - and can have less elements, defined by NumberOfRvaAndSizes.
In this case SizeOfOptionalHeader should reflect the header size as well (so that loader can figure out where section table start).