Added tests and javadocs