Added more tests. Fixed minor bugs. See issue #1.