Fixed bugs in query and FakeDynamo

Hello @giannic, @nicks, 

Please review the following commits I made in branch 'xiao-bugs'.

0466fc7a478ca4f4811c70a4a600fda5be1b90fb (2014-03-08 17:05:48 -0800)
Fixed bugs in query and FakeDynamo

R=@giannic
R=@nicks