On the Nitsche and the shifted penalty method