modernized MarginCriterion

I've modernized MarginCriterion to behave like other criterions. Previously it could use only the first element of an input tensor. Also added missing test for it.