fixing corner case bugs (like stats = 0) in optimizer test

in progress:
- verify that the counts calculated match and corner cases are handled