fixed lcm test and code, other minor bug fixes