Coinbase interview question

Given a piece of incorrect code and some failing test cases, debug and correct code.