fix nil checking and add test for nested boolean query