Add unit test for hook parsing, fix query parsing in metadata