added test files, patched misc. bugs