refactoring of the test infrastructure
add location retaining and fix several bugs