Added new tests; fixed bugs