It doesn't always work (but what does, right?), but it seems to help if I can involve DS in what I'm doing. If I'm trying to cook, I'll give him some potatoes, a scrub brush or old toothbrush, and a pot with a little water in it and let him "wash" the potatoes. One day I gave him a pitcher, a spoon, and a wet tea bag, and he "made tea" for a good 20 minutes (!).
When I'm doing laundry, his "job" is to pour the soap in the washing machine and to put the dryer balls in the dryer...and boy does he take it seriously! ;-)
As for the tantrums...what are you taking away from her? If it's a toy, could you give her a warning first? Like, "OK, DD, it's almost time for bed, so in five minutes we need to clean up your toys." Then repeat a couple times ("Two more minutes!"..."Ok, time's up!"). She obviously won't understand what "five minutes" means exactly, but she'll get the idea that it's a short, limited time.
If you're taking away something she's not supposed to have to begin with, like a dangerous or delicate item...well, I just tell my DS he can't have it along with a short explanation why, and then pretty much ignore any tantrum that follows.

Not in a mean way, but I just don't provide an audience.
I try not to look at it as him testing me so much as him being frustrated at being so little in a grown-up world, and at lacking the communication skills and ability to reign in his emotions that adults (usually) have.