corrections in algorithms to make rspec happier