Fixed URL generation for auto-formatted pages.
Added unit tests.