fixed script and add unit tests

patch for contribtest