I've seen plenty of debate about this, especially in communist spaces, calling into account Lenin's testament of:
"Comrade Stalin, having become Secretary-General, has unlimited authority concentrated in his hands, and I am not sure whether he will always be capable of using that authority with sufficient caution. Comrade Trotsky, on the other hand… is personally perhaps the most capable man in the present C.C.
Stalin is too rude and this defect, although quite tolerable in our midst and in dealing among us Communists, becomes intolerable in a Secretary-General. That is why I suggest that the comrades think about a way of removing Stalin from that post and appointing another man in his stead who in all other respects differs from Comrade Stalin in having only one advantage, namely, that of being more tolerant, more loyal, more polite and more considerate to the comrades, less capricious, etc."
However, I have also seen a fair bit of claims that say that Stalin was the preferred successor, and claiming this idea is based on misinformation or even outright propaganda. Knowing the general difficulty of studying the USSR without a political bias, I have been unable to work out who Lenin wished to be the successor.
Do any historians have any answers on this?
The classic academic overview of Lenin's final writings is Moshe Lewin's Lenin's Last Struggle, first published in 1968. Here, he points out that it is important to take Lenin's "Testament" in context, and as a series of documents rather than a single text.
The "Testament" was written (actually, dictated, since Lenin was unable to write at this point) over several days. The first quote you provide is from the first notes he dictated, on December 23rd-24th:
Comrade Stalin, having become Secretary General, has unlimited authority concentrated in his hands, and I am not sure whether he will always be capable of using that authority with sufficient caution. Comrade Trotsky, on the other hand, as his struggle with the CC on the question of the People's Commissiariat for Communications has already proved, is distinguished not only by outstanding ability. He is personally perhaps the most capable man in the present CC, but he has displayed excessive self-assurance and shown excessive preoccupation with the purely administrative side of the work.
As Lewin notes, this passage doesn't really favor either Stalin or Trotsky (or, for that matter, anyone mentioned in the Testament):
If the notes had stopped at this point and then been read out at a Party Congress, they would have appeared to the delegates to be mainly concerned with maintaining a proper balance within the leadership and avoiding a split. In fact, it is perfectly obvious that the equitable distribution of praise and blame in the document was fully intended.
In other words: these words were not intended to appoint a "successor" at all, but aimed at maintaining the existing balance of power within the Party leadership with some cautionary remarks on the potential flaws to be watched for in each leader.
Your second quote, however, comes from notes dictated much later, around January 4th:
Stalin is too rude, and this defect, though quite tolerable in our midst and in dealings among us Communists, becomes intolerable in a General Secretary. That is why I suggest that the comrades think about a way to remove Stalin from that post and appoint in his place another man who in all respects differs from Comrade Stalin in his superiority, that is, more tolerant, more loyal, more courteous and more considerate of the comrades, less capricious, etc.
Although this change of heart is sometimes explained by reference to Stalin's very rude treatment of Lenin's wife on December 22nd, Lewin suggests instead that it was for essentially political reasons. In his notes on the "national question," dictated December 30 and 31, Lenin expresses dissatisfaction with the way in which Stalin, Ordzhonikidze, and Dzerzhinsky are treating minority nations, and "roundly accuses Ordzhonikidze and Stalin of acting like Great Russian bullies[.]"
When we consider the text of the Testament in context, therefore, two things are clear. Firstly, Lenin was not interested in appointing Trotsky — or anyone — to be his "successor." The first notes of the Testament are in fact concerned with averting a potential split within the Party; such a thing would have been inconceivable if the Party were so monolithic as to simply follow Lenin's preferences blindly. In this sense Trotsky was not Lenin's preferred "successor," and Trotsky himself doesn't come out much better than anyone else in the Testament. Secondly, however, it is also clear that Lenin wants Stalin to be removed from his position following January 4th, which is a quite serious charge that no other member of the leadership is subjected to.
The consensus position is that the Testament is in fact genuine, and most people I have seen claim otherwise are into all sorts of Soviet pseudo-history like Grover Furr's writings.
Moshe Lewin, Lenin's Last Struggle, chapter six