Very perceptive observation. The behavior you're reporting is due to the fact that, right now, the local datastore isn't really transactional. Specifically, changes to attached objects become visible as soon as those updates are flushed rather than once the transaction commits. Your call to getObjectById is causing your change to b to be flushed to the datastore and that change is then visible when you read the list of B's that a owns. In production, the update to b isn't visible until after the transaction commits.
We have a rough plan to implement transactions in the local datastore in a way that more closely resembles prod, but feel free to file an issue so that you can get notified when we take care of it.