refactor and some more test