Correct error in addPreviouslyRefundedAmount

- correct logic
- create test