remove scan history from history query, refactor testing