fix bugs, add parameterized tests