Moroccans have voted in local polls seen as a test for the ruling party, who took power nearly four years ago after protests prompted reforms by the king.