These functions are tested as part of the integration tests for the trade functions, but we should go the extra mile and write unit tests for them.