Tests and some problems fixed