Bugfix: $query vs. $row variable
Added new test cases