Fix bug in tests. Change design to avoid circular dependency.