Fixed issue with order of commands and updated unit tests