Fix failing tests and warnings