Fixed issues, improved tests