refactor test suite and build script, reimplement some commands, add lots of comments