Unit tests that interact with the database operate on a single database connection. Since the connection returned for the DB_REPLICA flag is the same as the one returned for the DB_MASTER flag, code that attempts to write to the connection obtained with the DB_REPLICA flag will not fail.
This should be changed so that in tests, asking the LoadBalancer for a DB connection with the DB_REPLICA flag will return a wrapper that prevents write operations.