fix a problem found by sith with dynamic params (includes tests)