added missing robot bits, tests, refactoring