I would prefer an alteration of the floor plan: Installing a lavatory within the secure area of the cockpit.
That would cost only three passenger seats due to the fact that the then [former] forward passenger lavatory would be included to the flight deck. And the
new forward passenger WC is placed directly right to the door 1L.
This is not a costly measure.
Other way would be to install a computer-controlled cockpit door. In case of unlikely movements of the aircraft the door opens automatically.
They still need to open cockpit door for drinks/meals.