First of all the speed you are getting now is the speed you should get earlier.
To understand it you should understand about wifi device. It receive,drop and send packet instantly and always working, even when you are not connected to it. The device always sends broadcast or receive broadcast/multicast from surrounding devices such as IOT or Mobile Devices.
Which make the device to work constantly and throwing the packet all around, Now we can move to aluminum foil.. so you already have idea that the aluminum foil use to trap the heat or waves. So, when you surround your wifi device with aluminum and which leads to create a conical structure around wifi. So when you do that the data from the device roam easily but most of the packet which just not connecting to device are drop due to destination reachable. In the beginning the internet will looks sloppy and sluggy but after a while the unreachable packet will drop and the router will receive the widely packet via the conical space leaved around the antenna.
Whereas in your condition you already have 40 mbps connection, but due to packet collision, disruption and unreachable packets where congestion plays the lead roles. You were getting the low bandwidth. Since you covered the device with aluminum foil. The device getting narrow packet and connected devices preferred first and mostly unwanted packets drops which give you total bandwidth to have your fun.
Hope this is the conclusion of your question.
Guide me if I’m wrong… looking forward to know more stuffs.
Have a nice day.