Fixed compilation errors and fixed tests