refactor and extend tests