2 females in a 20 gallon should be fine, in theory. That said, my lone female lives in a 20 gallon long by herself. Really, they're better off housed singly, simply because then you never have to worry about dominance issues, feeding issues, health issues when one gets sick, etc.

If you really want to house them together anyway, it's best to have separate housing available in case any of the above problems occur, which would mean that you could just house them separately anyway.

As far as how many could live in a 40 breeder goes, that would really depend more on the floor space than anything else. A 20 long is 30 inches by 12 inches, or 2.5 square feet, and can reasonably house 1-2 leos, maybe 3, but IMO that'd be pushing it. A 40 breeder is 36 by 18 inches, or 4.5 square feet, so I'd say 3-4 leos there.