fix issue with circular deps and add tests