added test (#13)
improved handling of sub selects in SQL queries (#13)