Add support for specifying build directory for tests

Work in progress, don't merge yet