refactored pins.js and added more tests