When changing from calling B via the API of Y to a direct function call, you always need to change the code to achieve that.
If you feel the need to test a function in B from both project X and Y (because B or a component C that it depends on is implemented differently in the two projects, B1/B2 or C1/C2), then you need to write separate tests for the function at the project level, in X and/or Y.
Hope that answered your question.
Unfortunately, we don't get notified when people post here, and that's why the reply was late. You can "ping" us in the Slack channel to get our attention next time!