Write tests and functions
Fix merge error (reduce.js was deleted in Dennis version but I want to keep it in mine)