added ability to directly test with -test flag