correct bug uncovered by failing test
add a new test