Explain how dependency injection works in modern mobile development and why it is beneficial for unit testing.