refactor and modularize tests