Fix issue with package format detection and add test