Refactor parameter generation and fix tests