Dynamics of a two-mode Bose-Einstein condensate beyond mean-field theory