added test; fixed some issues