Small bug fixes
Add more tests