Some bugfixes
Add a test file