I agree with Confederacy of Dunces but I don't think I would call Bulgakov's novel a "laboratory". The seemingly abstract concept of evil and good, of religion and philosophy, is just a thin veneer painted on the terrible reality of the era Bulgakov was not able to describe explicitly. I was never quite sure if the readers in other countries can fully grasp the very real horror that unfolds on the pages of The Master and Margarita. People had very little chance to stick to their philosophies under those circumstances, as Bulgakov knew only too well.
On the lighter note, here is another "philosophical" novel (although I admit, it is a bit superficial) that comes to mind -
The Elegance of the Hedgehog by Muriel Barbery. Has anyone read it? I'm still not sure whether I liked it or not

Perhaps I was only referring to the general sense in which any serious novel can be analogous to the "laboratory", where theories are tested, and yes, even to the point of matters of "life and death".
But with Bulgakov I had in mind partly, his other novel, THE HEART OF A DOG, where actions take place in a literal laboratory to convert the dog into a pseudo-human.
By testing the Faustian principle in the laboratory of The MASTER AND MARGARITA, that the will to evil can sometimes produce good results inadvertently, perhaps Bulgakov is mirroring the opposite fact that Stalin's (or Mao's, or Pol-Pot's) Communist Will to Good, had so clearly produced the evil results you refer to quite rightly.
Bulgakov was one of the writers whose fiction was included in the 1991 Black Spring Press anthology of Stalinist-era Russian writers' short stories, THE TERRIBLE NEWS.
He was one of the few writers included in the anthology who was not murdered by Stalin's state for writing those stories.
And many of those doomed writers were clearly consciously aware that the new circumstances of the Communist era, had placed them in a deadly, cold, and yes, laboratory-like environment, where if you did not agree with the word of the doctors/scientists you would never leave the hospital alive.
As Zoshchenko's character says in that book, "We're not in the theatre comrades!The blood is real, and the pain is real, and the madness is real."
Bulgakov was perfectly aware of the "very real horror" of his circumstances, while his peer group of writers was being murdered, and his own work suppressed, but what was his response? To write to the Soviet Government in complaint at his own work's suppression, resulting in a phone call to his house from Stalin, which in turn led to Bulgakov's work at the Moscow Arts Theatre.
It's doubtful too that Bulgakov's vision in THE MASTER AND MARGARITA, its philosophical content, was only a thin veneer in place to disguise a political or social satire.
His father was a professor of theology, Bulgakov had internalised that deeply and long been attracted also to the very occultism and mysticism that Soviet thought-dictate had outlawed. No mere satire would have required the long, reverently detailed accounts of the meetings at the temple between Yeshua and Pontius Pilate set 2000 years before the book's other timeline.
It is a book of the spirit, and I would disagree that under the direst circumstances people have very little chance to stick to their philosophies.
History, and even the history of literature, shows that it is exactly in those circumstances where everything else has been stripped away that people find all they have left are their philosophies.
That is exactly the point of Boethius, and his book, THE CONSOLATION OF PHILOSOPHY.
It is, in a sense, the position in which Bulgakov ultimately found himself, terminally ill, blind, dictating corrections for his beloved manuscript from a bed, to his wife, THE MASTER AND MARGARITA being therefore his last testimony until he died at age 48, with his own philosophy still intact it seems, and there is far more to that philosophy than a mere political satire.
And, on a lighter note (!)...I didn't realise consciously when I brought up John Kennedy Toole...and Mikhail Bulgakov...these are both examples of authors whose novels were not published in their lifetime, suppressed one way or another, only to appear when, in Bulgakov's case, his wife got the book published 27 years after his death...or, in Toole's case, it was his mother who got his manuscript published 11 years after her son's death.
As Bulgakov wrote: "Manuscripts don't burn."
It is strange to think that these days, because of an ironically named device called a "kindle"...such cases of literary suppression may be less frequent.
All best,
John