:poop: Fix nitstats sql and improve tests
Merge pull request #1017 from rsslldnphy/fix/nitstats

Fix nitstats sql and improve tests