Fix bugs, add features to test.sh

gcc complained about a missing declaration for getpass(). Fixed by
including unistd.h.

test.sh didn't actually enter the password. Fixed with the expect
command. (Is this portable enough?)

The makefile tried to remove a directory with `rm -f'. Changed to
`rm -rf'.

Added features to test.sh: "number of tests" argument, sanity checks,
and a success counter.