Aftermarket sending unit not the same

I dont know why a sender would work in your hand and not work in the tank.
I know a crusty fuel line with crusty hangers may not provide a good ground path.
A crusty female connector on the harness can be a hit or miss connection.
i know there are some cheap senders undersized wire, plastic float, out there too. There is a contact in the sender that slides along a resistance wire winding. If the mechanical ( shaft and through holes ) is poorly built that moving contact might move away from the resistor. Just trying to help.