Testing improved, some redundant code removed