Performance of a prototype BGO calorimeter in an electron beam from 2 to 50 GeV