Added general code and tests