add test
fix code and add tests