fix test
restructure and refactor a bit