structure refactor for improved usability and tests