Fixed build tests. Added reference directory option.
Added Ref directory tests.