I have heard that Lord Brahma was cursed that, he will not be worshipped as a God in a test conducted by Lord shiva . So my question is what caused Lord Shiva to test Brahma and Vishnu?
As per, Shiva Purana: VIDYESHWAR SAMHITA:
A battle was fought between Lord Brahma and Lord Vishnu to prove their superiority. Lord Shiva manifested himself in the form of 'Analstamba' (pillar of fire) between them to stop the battle. Vishnu transformed himself into a boar and went to the 'Patal' (nether world) to find the base of that 'Pillar of fire'. Similarly Brahma transformed himself into a swan and flew up in the sky to find its limit.
Brahma then sought the help of Ketaki flower to give a false witness before lord Vishnu, that he (Brahma) had been successful in seeing the limit of that pillar of fire.
Lord Shiva then told Brahma:
"You spoke untruth with a desire to become worshippable. It is my curse that, you will not be worshipped by anybody. You will posses only four heads."
Brahma begged his forgiveness. Lord Shiva feeling pity on Brahma
gave him a boon of being the presiding deity of all the yagya.
the Ketaki flower also prohibited from being used during worship.
But when Ketaki flower tendered his apology Shiva gave blessing that
it would be fortunate to be offered to lord Vishnu during the worship.