Fix code to pass current unit tests