Made fixes, added test cases and plot example