Fix compiler warnings and test failures