It would be easy on the A380 that I fly to solve this.....merely move the locking door down to the bottom of the cockpit-access stairs. This would leave the flight deck with a self-contained lavatory and therefore nobody requiring to leve the flight deck for a physiological break.
It also has the added atteaction of not having pax coming up those stairs to the toilet, right outside of the flight deck, as is the case now. Still cant believe that this is deemed acceptable from a security point of view. But let us not digress with a debate on this bit!