Fixed a bug, added a test program