Fix warnings and some unit tests