Update .gitignore
Refactor and fix tests