Fixed compilation errors and unit tests