fixed schema row and table flattening, added tests