Moved command handling to the command package and added some tests