You are only taking time value of money into consideration in one part of your example and neglects it in the other?
But let's start at the beginning, by building up the cashflow of your original scenario:
| | t | t + 1 | t + 2 | t + 3 |
|-----------------|-------------|-----------|-----------|--------------|
| Cashflow | | 40.00 | 40.00 | 1,040.00 |
| Discount factor | | 1.04^1 | 1.04^2 | 1.04^3 |
|-----------------|-------------|-----------|-----------|--------------|
| PV | 1,000.00 | 38.46 | 36.98 | 924.56 |
Present value of your original scenario, with 4% interest is 1,000 dollars, which is fortunate, because this is what you have paid for the bond.
After we have received the first payment of 40 dollars, the Present Value of the bond (at t + 1) is:
| | t | t + 1 | t + 2 | t + 3 |
|-----------------|-------------|-----------|-----------|--------------|
| Cashflow | | | 40.00 | 1,040.00 |
| Discount factor | | | 1.04^1 | 1.04^2 |
|-----------------|-------------|-----------|-----------|--------------|
| PV | | 1,000.00 | 38.46 | 961.54 |
The price of the bond at t + 1 is still 1,000 because nohting has changed.
Now we introduce a change in interest rate going from 4% to 5%. Now the price of our bond changes:
| | t | t + 1 | t + 2 | t + 3 |
|-----------------|-------------|-----------|-----------|--------------|
| Cashflow | | | 40.00 | 1,040.00 |
| Discount factor | | | 1.05^1 | 1.05^2 |
|-----------------|-------------|-----------|-----------|--------------|
| PV | | 981.41 | 38.10 | 943.31 |
The price of our bond is now 981.41 (at t + 1).
Let's say we are to sell our bond in exchange for the new and improved 5% bond (with 2 years to maturity).
We now get the following cashflow:
| | t | t + 1 | t + 2 | t + 3 |
|-----------------|-------------|-----------|-----------|--------------|
| Cashflow | | | 49.73 | 1,030.48 |
| Discount factor | | | 1.05^1 | 1.05^2 |
|-----------------|-------------|-----------|-----------|--------------|
| PV | | 981.41 | 46.73 | 934.67 |
Note: 981.41 x 0.05 = 49.73
See how our PV of our bonds at t + 1 are the same in both scenarios?