DRYed out Java tests