Automate build, fix tests