Fixed some tests

code cleanup

Added inventory tests

Added permissions tests