Added dataloss unit test, improved other parts