generate and generate_n algorithms and tests