add shape tests, refactoring