Implement more Circuit functionality, and add test cases