Aha, yeah that'd explain it. That form of testing is useless. The starting slave is generated a bit differently. randomportrait only gets applied when slave is initially created. Your starting slave is generated with the default slave race, age, sex, and origins. Other attributes start as random. Portrait will be selected based upon that every single time. Then after all that, you're changing the race, age, sex.
Basically, your method of testing will never work, it'll always be searching for roughly the same attributes every time, regardless of what you chose. It'll always be matching a Human, Adult, Female, with random hair/skin/tits/ass.
I could look at inserting a call to randomportrait after you've selected your starting slave? Would basically need to add to _on_slaveconfirm_pressed a call to constructor.randomportrait(startSlave) at the start. Then this would apply to the starting slave. I can test this out and add it to later version of the mod, but with 0.5 your method of testing won't work.
I also wanted to figure out how to add a button to the "customization" tab of slaves to re-generate a random portrait, in case you modified etc. that'd also help solve this.
For my own testing, I load the game and go to slave markets. The slaves get regenerated every time you load, doesn't let me test everything but gets some sampling.