Fix tests and broken refactor

Change-Id: I00ccfb8646088b77a1316b86f8059b7252026ec7