Fix chunk count

When a file only has two chunks, the count was wrong and the header was
missing

TODO:
- [x] add unit test with 2 chunks