Adding tests for orb; fixing some bugs