Fix code to pass unit tests