Measure + test + some bugfixes in tests