cleaned up MaterializingScan and added tests