Added unit tests. Refactor to inject through constructors