Added more tests and some dependency injection