First pass at fixing #22

Hey guys, after some hacking I managed to get the has_many test to pass using sub selects.
The has many through case is still not working.  I've added test to show that behaviour.
I have to warn you, it's not pretty.

cc. @abenari, @brocktimus, @brunogh