Updating tests and fixing bugs