Fix manifest generation with complex versions

Until now, a package was removed (even with preserve_versions set to true) when its version component and name was the same as another package.
Instead, it should compare the full versions of the package (i.e. epoch, version, and iteration must be the same, not only the version).

Also added tests for the changes.