test the refactored code,
fix some issues