Some fuel pumps can develop internal leaks but show the same symptoms of a weak fuel pump that can deliver enough fuel when loads and engine speed increases. The most likely causes of this are leaky hoses inside the tank. Some fuel pump modules use clear corrugated flex hoses inside the tank. This hose is designed to stand up to fuel and can reduce noise from the fuel pump. This video is sponsored by Carter.
Some applications use SAE 30R10 fuel hose that is designed to be submerged in fuel. This type of hose has a special layer on the inside and outside to prevent the core layers from being saturated in fuel. If you use normal SAE rated fuel hose, it will degrade and start to leak inside the tank and cause an internal leak. Any restriction in the fuel lines means the electric pump has to turn faster to deliver the same amount of pressure at the fuel rail. If a fuel filter or sock in the tank is restricted, the fuel pressure at idle might be within specifications. But during increased engine loads and speeds, the engine will be starved for fuel.
If the fuel pump is replaced, any filter or screen should be inspected and replaced if possible. Some direct-injection high-pressure pumps will have screens on the inlet. Often the bits and pieces of the old electric pump in the tank will be trapped on these screens.