Added tests. Fixed datasets metadata persistence