Fix tests and improve check