Unit test major refactoring for better and more robust i/o of test data. Also corresponding tests to latest fixes