refactor and add pages, clean up tests