Added tests. Working nicely except that the order of fields is unpredictable