added autodetection per file. fixed broken tests.