Add file locking
Add more unit tests
Bugfixing after unit tests