Added sweep test, and fix bug in sweep