I have actually read your question many times to make sure that I have grasped everything you needed a clarification about. From what I have read, I understand that by the term 'Baitul Muqaddas', you are referring to Al-Aqsa Mosque in Jerusalem.
Based on this understanding, I will answer your questions. Yet, there is one important fact that we should highlight before we tackle these questions. A believer's faith is always tested by subjecting it to Divine commands because the very essence of the meaning of the word Islam is submission.
When Muslims accept Islam as their religion and way of life, they implicitly agree to submit, in all their actions, to the will of Allah. Sometimes, this has to be put to test to see if their sense and understanding of submission is genuine or not. This holds true for both individuals and communities.
When Almighty Allah commanded the Prophet (peace be upon him) to face the qiblah of Al-Aqsa Mosque in Jerusalem and then commanded him to face the Kabah as his qiblah (direction of prayer), that was an actual test for the community of believers as well as the surrounding society. It was firstly to test the faith of the individuals and secondly to show them certain things they might not be aware of.
Now, coming to the story of the qiblah, I would like to tell you that this issue has gone through three stages.
Al-Israa' and Al-Miraj
This stage started from the event of Al-Israa' and Al-Miraj (Night Journey and Ascension), the night in which five daily prayers were firstly prescribed. On that day, Almighty Allah made it obligatory for Muslims to pray five times a day and that happened while the Prophet was still in Makkah.
The direction Muslims were commanded to face at that time was the Kabah in Makkah on the condition that it has to be faced in a way that make them face Al-Aqsa Mosque in Jerusalem at the same time.
Obviously, facing the direction of Al-Aqsa Mosque while in Makkah means facing the Kabah at the same time, simply because the geographical location of Makkah happens to be south east of Jerusalem and therefore, Muslims were facing two qiblahs at the one time. (Muhammed Abu Zahra, Khatim Al-Nabiyeen, Vol. 2, Dar Al-Fikr Al-Arabi, 2004 pp. 538)
This direction in which Muslims were facing both Kabah and Al-Aqsa stressed the connection between Prophet Muhammad and Prophet Abraham (peace be upon them) and the connection between Prophet Muhammad and all Israelite Prophets including Moses and Jesus (peace be upon them).
Moving to Madinah
When Prophet Muhammad moved to Madinah, it was geographically and physically impossible to face both qiblahs at the same time, simply because Madinah is between Makkah and Jerusalem.
Therefore, Muslims were facing the direction of Al-Aqsa Mosque in Jerusalem as a fulfillment of Allah's command and an indication of their full submission to His Will. This was the test in which Muslims proved their full submission to Allah and acceptance of whatever He commands them to do.
They have proved how they understood their religion; that all directions belong to Allah and to Him we should turn our hearts before our faces. To Allah belongs the kingdom of earth and heavens and to Him all directions do belong.
A Muslim, as a part of this universe, belongs to His Creator and therefore, as part of this belonging, should turn his face wherever the Creator commands.
Obviously as explained in the Quran, the new stage where Muslims were facing Jerusalem was a test and one of the natures of a test is its being temporary; it is not the default.
The benefit of the test was to show people their own true colors and prove to them that they will be subject to an attack even from followers of close religions who live with them in the same society.
The test was to make them strong enough to bear that type of tribulations in the future and, more importantly, to give sometime for the Kabah to be cleared from the idols that were surrounding it.
Deep from within, the Prophet was longing to the qiblah of his father Abraham, and it seems as some commentators opine that he realized that the command to face Jerusalem was a temporary one and soon he will be commanded to turn his face to the Kabah.
Before the Battle
After sixteen or seventeen months of facing Jerusalem, and right before the Battle of Badr which marked the true confrontation between truth and falsehood and the beginning of the collapse of idolatry, the Prophet received commands from his Lord to face the Kabah again; i.e. to get back to the first qiblah.
The happiness of the Prophet and the Muslim community with the command was great and significant. It proved to them that soon the idols will be removed from around the Kabah and it will be purified. Not long time afterwards that the Prophet returned to Makkah and the Divine grace was completed upon him.
With regard to the issue of the idols around the Kabah, it should be understood that the Prophet was not facing the idols; rather, he was facing the Kabah and the idols were around not inside or beside it.
As for the issue of the garbage around Al-Aqsa Mosque, it is historically mentioned. Al-Aqsa mosque was established long time ago before Prophet Muhammad and Prophet Moses.
It is said that it was established 40 years after the Holy Mosque in Makkah and some commentators say it was established during the time of Prophet Solomon.
This means that it was a mosque even before Prophet Muhammad and when Umar (may Allah be pleased with him) conquered Jerusalem to retake it, he was actually taking it as a mosque. The garbage was a temporary thing piled around it by the Roman occupiers who disrespected the mosque and gave no care to it.
May Allah return Al-Aqsa Mosque to us and hasten its liberation from the hands of its occupiers!