added tests, modified some inconsistencies in the basecode