Fix housekeeping bug, and add low level discovery tests