Fixes and test added

I added some fixes for example for headings processing. I also added some unit tests.