Convert samtools stats to htslib and add some tests

Converts samtools stats to htslib use the htslib API rather than legacy samtools and add some tests.