add mocha dev dependancy
change callback to have error first

some error handling also implemented
added some tests