Fix tests and router bugs