add test code and fix scope of options