Add some tests + refactored others